@@ -105,7 +105,7 @@ m_Minimised (true) | |||
if (m_PluginWindow) { | |||
m_PluginWindow->hide(); | |||
add (m_PluginWindow); | |||
m_PluginWindow->ResizeCallback (&cb_Resize, this); | |||
m_PluginWindow->SetResizeCallback (&cb_Resize, this); | |||
} | |||
resizable(NULL); | |||
//Add the input/output ports | |||
@@ -154,15 +154,13 @@ void Fl_DeviceGUI::ResizeToPluginWindow (void) { | |||
void Fl_DeviceGUI::Minimise() { | |||
m_Minimised = true; | |||
Resize (m_MiniWidth, m_MiniHeight); | |||
parent()->redraw(); | |||
} | |||
void Fl_DeviceGUI::Maximise() { | |||
m_Minimised=false; | |||
ResizeToPluginWindow(); | |||
m_PluginWindow->show(); | |||
m_IconButton->hide(); | |||
parent()->redraw(); | |||
ResizeToPluginWindow(); | |||
((Fl_Canvas*)parent())->ToTop(this); | |||
} | |||
@@ -178,6 +176,7 @@ void Fl_DeviceGUI::Resize (int width, int height) { | |||
int Centx = x()+w()/2; | |||
int Centy = y()+h()/2; | |||
m_IconButton->position (Centx-m_Icon->w()/2, Centy-m_Icon->h()/2); | |||
parent()->redraw(); | |||
} | |||
void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | |||
@@ -21,14 +21,14 @@ | |||
#include <FL/Fl_Group.H> | |||
class Fl_DeviceGUI; | |||
class SpiralGUIType; | |||
typedef void (SpiralGUISizeCB)(Fl_DeviceGUI *o); | |||
class SpiralGUIType : public Fl_Group { | |||
public: | |||
SpiralGUIType (int x, int y, int w, int h, const char *label = 0); | |||
~SpiralGUIType (); | |||
void ResizeCallback (SpiralGUISizeCB *c, Fl_DeviceGUI *d) { m_ResizeSpiralGUI = c; m_DeviceGUI = d; } | |||
void SetResizeCallback (SpiralGUISizeCB *c, Fl_DeviceGUI *d) { m_ResizeSpiralGUI = c; m_DeviceGUI = d; } | |||
protected: | |||
void DoResizeCallback (void) { if (m_ResizeSpiralGUI) m_ResizeSpiralGUI(m_DeviceGUI); } | |||
private: | |||
@@ -14,7 +14,7 @@ | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
*/ | |||
*/ | |||
#include "Midi.h" | |||
#include "unistd.h" | |||
@@ -25,7 +25,7 @@ | |||
static const int MIDI_SCANBUFSIZE=256; | |||
static const int MIDI_KEYOFFSET=0; | |||
static const unsigned char STATUS_START = 0x80; | |||
static const unsigned char STATUS_START = 0x80; | |||
static const unsigned char STATUS_NOTE_OFF = 0x80; | |||
static const unsigned char STATUS_NOTE_ON = 0x90; | |||
static const unsigned char STATUS_AFTERTOUCH = 0xa0; | |||
@@ -40,97 +40,63 @@ static const unsigned char MIDI_CLOCK = 0xf8; | |||
static const unsigned char ACTIVE_SENSE = 0xfe; | |||
static int NKEYS = 30; | |||
MidiDevice *MidiDevice::m_Singleton; | |||
string MidiDevice::m_AppName; | |||
#ifdef OSS_MIDI | |||
string MidiDevice::m_DeviceName; | |||
string MidiDevice::m_AppName; | |||
#endif | |||
#if __APPLE__ | |||
#define read AppleRead | |||
#endif | |||
void MidiDevice::Init(const string &name, Type t) | |||
{ | |||
if (!m_Singleton) | |||
void MidiDevice::Init(const string &name, Type t) | |||
{ | |||
if (!m_Singleton) | |||
{ | |||
m_AppName=name; | |||
m_Singleton=new MidiDevice(t); | |||
m_Singleton=new MidiDevice(t); | |||
} | |||
} | |||
MidiDevice::MidiDevice(Type t) : | |||
m_Poly(1), | |||
m_Clock(1.0f), | |||
m_ClockCount(0) | |||
{ | |||
Open(t); | |||
} | |||
MidiDevice::~MidiDevice() | |||
MidiDevice::MidiDevice(Type t) : | |||
m_Poly (1), | |||
m_Clock (1.0f), | |||
m_ClockCount (0) | |||
{ | |||
#if __APPLE__ | |||
AppleOpen(); | |||
#endif | |||
#ifdef ALSA_MIDI | |||
snd_seq_close (seq_handle); | |||
#else | |||
Close(); | |||
seq_handle=AlsaOpen(t); | |||
#endif | |||
#ifdef OSS_MIDI | |||
if (!OssOpen()) return; | |||
#endif | |||
m_Mutex = new pthread_mutex_t; | |||
pthread_mutex_init (m_Mutex, NULL); | |||
pthread_create (&m_MidiReader, NULL, (void*(*)(void*))MidiDevice::MidiReaderCallback, (void*)this); | |||
} | |||
void MidiDevice::Close() | |||
{ | |||
#if __APPLE__ | |||
AppleClose(); | |||
#else | |||
pthread_mutex_lock(m_Mutex); | |||
pthread_cancel(m_MidiReader); | |||
pthread_mutex_unlock(m_Mutex); | |||
pthread_mutex_destroy(m_Mutex); | |||
close(m_MidiFd); | |||
close(m_MidiWrFd); | |||
cerr<<"Closed midi device"<<endl; | |||
#endif // !__APPLE__ | |||
} | |||
void MidiDevice::Open(Type t) | |||
{ | |||
MidiDevice::~MidiDevice() { | |||
pthread_mutex_lock (m_Mutex); | |||
pthread_cancel (m_MidiReader); | |||
pthread_mutex_unlock (m_Mutex); | |||
pthread_mutex_destroy (m_Mutex); | |||
#if __APPLE__ | |||
AppleOpen(); | |||
#else | |||
#ifdef ALSA_MIDI | |||
seq_handle=AlsaOpen(t); | |||
#else | |||
//if (!SpiralInfo::WANTMIDI) return; | |||
m_MidiFd = open(m_DeviceName.c_str(),O_RDONLY|O_SYNC); | |||
if (!m_MidiFd) | |||
{ | |||
cerr<<"Couldn't open midi for reading ["<<m_DeviceName<<"]"<<endl; | |||
return; | |||
} | |||
m_MidiWrFd = open(m_DeviceName.c_str(),O_WRONLY); | |||
if (!m_MidiWrFd) | |||
{ | |||
cerr<<"Couldn't open midi for writing ["<<m_DeviceName<<"]"<<endl; | |||
return; | |||
} | |||
cerr<<"Opened midi device ["<<m_DeviceName<<"]"<<endl; | |||
AppleClose(); | |||
#endif | |||
#endif // !__APPLE__ | |||
m_Mutex = new pthread_mutex_t; | |||
pthread_mutex_init(m_Mutex, NULL); | |||
#ifdef ALSA_MIDI | |||
pthread_create(&m_MidiReader,NULL,(void*(*)(void*))MidiDevice::AlsaMidiReaderCallback,(void*)this); | |||
#else | |||
pthread_create(&m_MidiReader,NULL,(void*(*)(void*))MidiDevice::MidiReaderCallback,(void*)this); | |||
AlsaClose(); | |||
#endif | |||
#ifdef OSS_MIDI | |||
OssClose(); | |||
#endif | |||
} | |||
// returns the next event off the list, or an | |||
// returns the next event off the list, or an | |||
// empty event if the list is exhausted | |||
MidiEvent MidiDevice::GetEvent(int Device) | |||
{ | |||
@@ -146,7 +112,7 @@ MidiEvent MidiDevice::GetEvent(int Device) | |||
pthread_mutex_unlock(m_Mutex); | |||
return MidiEvent(MidiEvent::NONE,0,0); | |||
} | |||
MidiEvent event(m_EventVec[Device].front()); | |||
m_EventVec[Device].pop(); | |||
pthread_mutex_unlock(m_Mutex); | |||
@@ -154,8 +120,7 @@ MidiEvent MidiDevice::GetEvent(int Device) | |||
return event; | |||
} | |||
void MidiDevice::SendEvent(int Device,const MidiEvent &Event) | |||
{ | |||
void MidiDevice::SendEvent (int Device, const MidiEvent &Event) { | |||
#ifdef ALSA_MIDI | |||
snd_seq_event_t ev; | |||
snd_seq_ev_clear (&ev); | |||
@@ -188,58 +153,82 @@ void MidiDevice::SendEvent(int Device,const MidiEvent &Event) | |||
} | |||
char message[3]; | |||
message[1]=Event.GetNote()+MIDI_KEYOFFSET; | |||
message[2]=(char)Event.GetVolume(); | |||
if (Event.GetType()==MidiEvent::ON) | |||
{ | |||
message[0]=STATUS_NOTE_ON+Device; | |||
write(m_MidiWrFd,message,3); | |||
//cerr<<"sending "<<message<<endl; | |||
} | |||
if (Event.GetType()==MidiEvent::OFF) | |||
{ | |||
message[0]=STATUS_NOTE_OFF+Device; | |||
write(m_MidiWrFd,message,3); | |||
write(m_MidiWrFd,message,3); | |||
//cerr<<"sending "<<message<<endl; | |||
} | |||
#endif | |||
} | |||
///////////////////////////////////////////////////////////////////////////////// | |||
// Reader thread functions | |||
//////////////////////////////////////////// Oss Code Only //////////////////////////////////////// | |||
#ifdef OSS_MIDI | |||
bool MidiDevice::OssOpen() { | |||
//if (!SpiralInfo::WANTMIDI) return; | |||
m_MidiFd = open (m_DeviceName.c_str(), O_RDONLY | O_SYNC); | |||
if (!m_MidiFd) { | |||
cerr << "Couldn't open midi for reading [" << m_DeviceName << "]" << endl; | |||
return false; | |||
} | |||
m_MidiWrFd = open (m_DeviceName.c_str(), O_WRONLY); | |||
if (!m_MidiWrFd) { | |||
cerr << "Couldn't open midi for writing [" << m_DeviceName << "]" << endl; | |||
return false; | |||
} | |||
cerr << "Opened midi device [" << m_DeviceName << "]" << endl; | |||
return true; | |||
} | |||
void MidiDevice::OssClose() { | |||
close(m_MidiFd); | |||
close(m_MidiWrFd); | |||
cerr<<"Closed midi device"<<endl; | |||
} | |||
// little helper to strip out the realtime and unused messages | |||
void MidiDevice::ReadByte(unsigned char *c) | |||
void MidiDevice::OssReadByte(unsigned char *c) | |||
{ | |||
*c=ACTIVE_SENSE; | |||
do read(m_MidiFd,c,1); | |||
while (*c>=STATUS_END && *c!=MIDI_CLOCK); | |||
do read(m_MidiFd,c,1); | |||
while (*c>=STATUS_END && *c!=MIDI_CLOCK); | |||
} | |||
// collect events deals with the byte level messages, and sorts | |||
// collect events deals with the byte level messages, and sorts | |||
// and filters them into distinct messages we can handle easily | |||
void MidiDevice::CollectEvents() | |||
{ | |||
unsigned char buf[1]; | |||
void MidiDevice::OssCollectEvents() | |||
{ | |||
unsigned char buf[1]; | |||
int count,n,nn; | |||
bool MessageSent; | |||
unsigned char data[3],last=0; | |||
// constantly scan for relevent input, | |||
// and write it to the pipe | |||
// filters out unhandled messages, and attempts to build | |||
// filters out unhandled messages, and attempts to build | |||
// coherent messages to send to the midi handler | |||
bool InSysex=false; | |||
for(;;) | |||
{ | |||
ReadByte(buf); | |||
if (*buf==MIDI_CLOCK) | |||
OssReadByte(buf); | |||
if (*buf==MIDI_CLOCK) | |||
{ | |||
m_ClockCount++; | |||
if (m_ClockCount==6) | |||
@@ -250,65 +239,65 @@ void MidiDevice::CollectEvents() | |||
} | |||
else | |||
if (*buf>=STATUS_START) // we've got a status byte | |||
{ | |||
{ | |||
if (*buf==SYSEX_TERMINATOR) InSysex=false; | |||
// find out if it's an opcode | |||
if(*buf>=STATUS_START && *buf<=STATUS_END) | |||
{ | |||
if(*buf>=STATUS_START && *buf<=STATUS_END) | |||
{ | |||
InSysex=false; | |||
last=data[0]=*buf; | |||
if (data[0]>=STATUS_PROG_CHANGE && data[0]<STATUS_PITCH_WHEEL) | |||
if (data[0]>=STATUS_PROG_CHANGE && data[0]<STATUS_PITCH_WHEEL) | |||
{ | |||
ReadByte(&data[1]); //one byte | |||
OssReadByte(&data[1]); //one byte | |||
data[2]=0; | |||
} | |||
else // get the next two bytes | |||
{ | |||
ReadByte(&data[1]); | |||
ReadByte(&data[2]); | |||
{ | |||
OssReadByte(&data[1]); | |||
OssReadByte(&data[2]); | |||
} | |||
AddEvent(data); | |||
} | |||
OssAddEvent(data); | |||
} | |||
else // its a sysex or other message like active sense | |||
{ | |||
{ | |||
if (*buf==SYSEX_START) InSysex=true; | |||
cerr<<"Unhandled midi message: "; printf("%x\n",(int)*buf); | |||
cerr<<"Unhandled midi message: "; printf("%x\n",(int)*buf); | |||
} | |||
} | |||
else // more data (running status) | |||
else // more data (running status) | |||
{ | |||
if (!InSysex) | |||
if (!InSysex) | |||
{ | |||
data[0]=last; | |||
data[1]=*buf; | |||
if (data[0]>=STATUS_PROG_CHANGE && data[0]<STATUS_PITCH_WHEEL) | |||
{ | |||
if (data[0]>=STATUS_PROG_CHANGE && data[0]<STATUS_PITCH_WHEEL) | |||
{ | |||
data[2]=0; //one byte | |||
} | |||
else // get the next byte | |||
{ | |||
ReadByte(&data[2]); | |||
{ | |||
OssReadByte(&data[2]); | |||
} | |||
AddEvent(data); | |||
OssAddEvent(data); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
// addevent converts the midi bytecode into midi message objects and | |||
// addevent converts the midi bytecode into midi message objects and | |||
// stacks them onto the event list to be picked up by the app | |||
void MidiDevice::AddEvent(unsigned char* midi) | |||
{ | |||
void MidiDevice::OssAddEvent(unsigned char* midi) | |||
{ | |||
MidiEvent::type MessageType=MidiEvent::NONE; | |||
int Volume=0,Note=0,EventDevice=0; | |||
int Volume=0,Note=0,EventDevice=0; | |||
// note off | |||
if (midi[0] >= STATUS_NOTE_OFF && midi[0] < STATUS_NOTE_ON) | |||
{ | |||
if (midi[0] >= STATUS_NOTE_OFF && midi[0] < STATUS_NOTE_ON) | |||
{ | |||
MessageType=MidiEvent::OFF; | |||
Note=midi[1]-MIDI_KEYOFFSET; | |||
EventDevice=midi[0]-STATUS_NOTE_OFF; | |||
@@ -317,8 +306,8 @@ void MidiDevice::AddEvent(unsigned char* midi) | |||
else if (midi[0] >= STATUS_NOTE_ON && midi[0] < STATUS_AFTERTOUCH) | |||
{ | |||
Volume = midi[2]; | |||
// cope with Roland equipment, where note on's | |||
// cope with Roland equipment, where note on's | |||
// with zero velocity are sent as note offs. | |||
if (Volume) MessageType=MidiEvent::ON; | |||
else MessageType=MidiEvent::OFF; | |||
@@ -328,15 +317,15 @@ void MidiDevice::AddEvent(unsigned char* midi) | |||
} | |||
// aftertouch | |||
else if (midi[0] >= STATUS_AFTERTOUCH && midi[0] < STATUS_CONTROL_CHANGE) | |||
{ | |||
{ | |||
MessageType=MidiEvent::AFTERTOUCH; | |||
Note=midi[1]-MIDI_KEYOFFSET; | |||
Volume=midi[2]; | |||
Note=midi[1]-MIDI_KEYOFFSET; | |||
Volume=midi[2]; | |||
EventDevice=midi[0]-STATUS_AFTERTOUCH; | |||
} | |||
// parameter | |||
else if (midi[0] >= STATUS_CONTROL_CHANGE && midi[0] < STATUS_PROG_CHANGE) | |||
{ | |||
{ | |||
MessageType=MidiEvent::PARAMETER; | |||
Note=midi[1]; | |||
Volume=midi[2]; | |||
@@ -344,20 +333,20 @@ void MidiDevice::AddEvent(unsigned char* midi) | |||
} | |||
// channel pressure | |||
else if (midi[0] >= STATUS_CHANNEL_PRESSURE && midi[0] < STATUS_PITCH_WHEEL) | |||
{ | |||
MessageType=MidiEvent::CHANNELPRESSURE; | |||
Volume=midi[1]; | |||
{ | |||
MessageType=MidiEvent::CHANNELPRESSURE; | |||
Volume=midi[1]; | |||
EventDevice=midi[0]-STATUS_CHANNEL_PRESSURE; | |||
} | |||
// note pitchbend | |||
else if (midi[0] >= STATUS_PITCH_WHEEL && midi[0] < STATUS_END) | |||
{ | |||
{ | |||
MessageType=MidiEvent::PITCHBEND; | |||
// should probably take the first byte into account too? | |||
Volume=midi[2]; | |||
Volume=midi[2]; | |||
EventDevice=midi[0]-STATUS_PITCH_WHEEL; | |||
} | |||
if (EventDevice<0 || EventDevice>15) | |||
{ | |||
cerr<<"Error - Midi device "<<EventDevice<<" ??"<<endl; | |||
@@ -369,43 +358,50 @@ void MidiDevice::AddEvent(unsigned char* midi) | |||
pthread_mutex_unlock(m_Mutex); | |||
} | |||
/////////////////////////////////////////////////////////////////////////////// | |||
#endif | |||
//////////////////////////////////////////// Alsa Code Only //////////////////////////////////////// | |||
#ifdef ALSA_MIDI | |||
// code taken and modified from jack_miniFMsynth | |||
void MidiDevice::AlsaCollectEvents() | |||
void MidiDevice::AlsaClose () { | |||
snd_seq_close (seq_handle); | |||
} | |||
void MidiDevice::AlsaCollectEvents() | |||
{ | |||
int seq_nfds, l1; | |||
struct pollfd *pfds; | |||
seq_nfds = snd_seq_poll_descriptors_count(seq_handle, POLLIN); | |||
pfds = (struct pollfd *)alloca(sizeof(struct pollfd) * seq_nfds); | |||
snd_seq_poll_descriptors(seq_handle, pfds, seq_nfds, POLLIN); | |||
for(;;) | |||
{ | |||
if (poll (pfds, seq_nfds, 1000) > 0) | |||
{ | |||
if (poll (pfds, seq_nfds, 1000) > 0) | |||
{ | |||
for (l1 = 0; l1 < seq_nfds; l1++) | |||
for (l1 = 0; l1 < seq_nfds; l1++) | |||
{ | |||
if (pfds[l1].revents > 0) | |||
{ | |||
{ | |||
snd_seq_event_t *ev; | |||
int l1; | |||
MidiEvent::type MessageType=MidiEvent::NONE; | |||
int Volume=0,Note=0,EventDevice=0; | |||
do | |||
int Volume=0,Note=0,EventDevice=0; | |||
do | |||
{ | |||
snd_seq_event_input(seq_handle, &ev); | |||
if ((ev->type == SND_SEQ_EVENT_NOTEON) && (ev->data.note.velocity == 0)) | |||
if ((ev->type == SND_SEQ_EVENT_NOTEON) && (ev->data.note.velocity == 0)) | |||
{ | |||
ev->type = SND_SEQ_EVENT_NOTEOFF; | |||
ev->type = SND_SEQ_EVENT_NOTEOFF; | |||
} | |||
switch (ev->type) { | |||
case SND_SEQ_EVENT_PITCHBEND: | |||
MessageType=MidiEvent::CHANNELPRESSURE; | |||
MessageType=MidiEvent::CHANNELPRESSURE; | |||
Volume = (char)((ev->data.control.value / 8192.0)*256); | |||
break; | |||
case SND_SEQ_EVENT_CONTROLLER: | |||
@@ -418,17 +414,17 @@ void MidiDevice::AlsaCollectEvents() | |||
EventDevice = ev->data.control.channel; | |||
Note = ev->data.note.note; | |||
Volume = ev->data.note.velocity; | |||
break; | |||
break; | |||
case SND_SEQ_EVENT_NOTEOFF: | |||
MessageType=MidiEvent::ON; | |||
EventDevice = ev->data.control.channel; | |||
Note = ev->data.note.note; | |||
break; | |||
break; | |||
} | |||
pthread_mutex_lock(m_Mutex); | |||
m_EventVec[EventDevice].push(MidiEvent(MessageType,Note,Volume)); | |||
pthread_mutex_unlock(m_Mutex); | |||
snd_seq_free_event(ev); | |||
} while (snd_seq_event_input_pending(seq_handle, 0) > 0); | |||
} | |||
@@ -437,11 +433,11 @@ void MidiDevice::AlsaCollectEvents() | |||
} | |||
} | |||
snd_seq_t *MidiDevice::AlsaOpen(Type t) | |||
snd_seq_t *MidiDevice::AlsaOpen(Type t) | |||
{ | |||
snd_seq_t *seq_handle; | |||
int client_id, port_id; | |||
if (t==WRITE) | |||
{ | |||
if (snd_seq_open(&seq_handle, "default", SND_SEQ_OPEN_OUTPUT, 0) < 0) { | |||
@@ -475,26 +471,28 @@ snd_seq_t *MidiDevice::AlsaOpen(Type t) | |||
#endif | |||
//////////////////////////////////////////// Apple Code Only ///////////////////////////////////////// | |||
#if __APPLE__ | |||
void MidiDevice::AppleOpen() | |||
{ | |||
m_ReadFillIndex = m_ReadReadIndex = 0; | |||
OSStatus err = 0; | |||
mMIDISource = NULL; | |||
mMIDIClient = NULL; | |||
mMIDIDestination = NULL; | |||
err = MIDIClientCreate(CFSTR("org.pawpal.ssm"), NULL, NULL, &mMIDIClient); | |||
if (err) printf("MIDIClientCreate failed returned %d\n", err); | |||
if (!err) { | |||
err = MIDISourceCreate(mMIDIClient, CFSTR("SpiralSynth"), &mMIDISource); | |||
if (err) printf("MIDIInputPortCreate failed returned %d\n", err); | |||
} | |||
if (!err) { | |||
err = MIDIDestinationCreate(mMIDIClient, CFSTR("SpiralSynth"), sMIDIRead, this, &mMIDIDestination); | |||
MIDIObjectSetIntegerProperty(mMIDIDestination, kMIDIPropertyUniqueID, 'SSmP'); | |||
@@ -543,7 +541,7 @@ int MidiDevice::AppleRead(int dummy, unsigned char *outbuffer, int maxlen) | |||
void MidiDevice::sMIDIRead(const MIDIPacketList *pktlist, void *readProcRefCon, void *srcConnRefCon) | |||
{ | |||
MidiDevice & t = *((MidiDevice*)readProcRefCon); | |||
const MIDIPacket *packet = &pktlist->packet[0]; | |||
for (int i = 0; i < (int)pktlist->numPackets; i++) { | |||
const MIDIPacket & p = *packet; | |||
@@ -30,7 +30,10 @@ | |||
using namespace std; | |||
// comment out one of these to choose your MIDI driver (for non-Apple systems) | |||
// I'll stick this in the ./configue when it'd all working | |||
#define ALSA_MIDI | |||
//#define OSS_MIDI | |||
#ifdef ALSA_MIDI | |||
#include <alsa/asoundlib.h> | |||
@@ -46,9 +49,9 @@ public: | |||
enum type{NONE,ON,OFF,AFTERTOUCH,PARAMETER,CHANNELPRESSURE,PITCHBEND}; | |||
MidiEvent() {m_Type=NONE;} | |||
MidiEvent(type t, int note, float v) | |||
MidiEvent(type t, int note, float v) | |||
{m_Type=t; m_Note=note; m_Volume=v;} | |||
type GetType() const {return m_Type;} | |||
float GetVolume() const {return m_Volume;} | |||
int GetNote() const {return m_Note;} | |||
@@ -66,9 +69,13 @@ public: | |||
enum Type{READ,WRITE}; | |||
static void Init(const string &name, Type t); | |||
static void SetDeviceName(string s) { m_DeviceName=s; } | |||
static MidiDevice *Get() { return m_Singleton; } | |||
static void PackUpAndGoHome() { if(m_Singleton) delete m_Singleton; m_Singleton=NULL; } | |||
static void SetDeviceName(string s) { | |||
#ifdef OSS_MIDI | |||
m_DeviceName=s; | |||
#endif | |||
} | |||
static MidiDevice *Get() { return m_Singleton; } | |||
static void PackUpAndGoHome() { if (m_Singleton) delete m_Singleton; m_Singleton=NULL; } | |||
MidiEvent GetEvent(int Device); | |||
void SendEvent(int Device,const MidiEvent &Event); | |||
@@ -76,47 +83,43 @@ public: | |||
void SetPoly(int s) { m_Poly=s; } | |||
float GetClock() { return m_Clock; } | |||
private: | |||
MidiDevice(Type t); | |||
void Open(Type t); | |||
void Close(); | |||
void CollectEvents(); | |||
void AddEvent(unsigned char* midi); | |||
void ReadByte(unsigned char *c); | |||
static void *MidiReaderCallback(void *o) { ((MidiDevice*)o)->CollectEvents(); return NULL; } | |||
int m_MidiFd; | |||
int m_MidiWrFd; | |||
static string m_DeviceName; | |||
int m_Poly; | |||
float m_Clock; | |||
int m_ClockCount; | |||
queue<MidiEvent> m_EventVec[16]; | |||
static MidiDevice *m_Singleton; | |||
pthread_t m_MidiReader; | |||
pthread_mutex_t* m_Mutex; | |||
static string m_AppName; | |||
static string m_AppName; | |||
#ifdef ALSA_MIDI | |||
static void *AlsaMidiReaderCallback(void *o) { ((MidiDevice*)o)->AlsaCollectEvents(); return NULL; } | |||
static void *MidiReaderCallback (void *o) { ((MidiDevice*)o)->AlsaCollectEvents(); return NULL; } | |||
void AlsaCollectEvents(); | |||
void AlsaClose (); | |||
snd_seq_t *seq_handle; | |||
snd_seq_t *AlsaOpen(Type t); | |||
#endif | |||
#ifdef OSS_MIDI | |||
static void *MidiReaderCallback (void *o) { ((MidiDevice*)o)->OssCollectEvents(); return NULL; } | |||
void OssCollectEvents(); | |||
void OssAddEvent(unsigned char* midi); | |||
void OssReadByte(unsigned char *c); | |||
void OssClose(); | |||
static string m_DeviceName; | |||
int m_MidiFd, m_MidiWrFd; | |||
#endif | |||
#if __APPLE__ | |||
MIDIClientRef mMIDIClient; | |||
MIDIEndpointRef mMIDISource; | |||
MIDIEndpointRef mMIDIDestination; | |||
#define midi_ReadSize 4096 | |||
unsigned char m_ReadBuffer[midi_ReadSize]; | |||
volatile int m_ReadFillIndex; | |||
@@ -126,10 +129,10 @@ private: | |||
void MidiDevice::AppleClose(); | |||
int MidiDevice::AppleWrite(int dummy, unsigned char *outbuffer, int maxlen); | |||
int MidiDevice::AppleRead(int dummy, unsigned char *outbuffer, int maxlen); | |||
static void MidiDevice::sMIDIRead(const MIDIPacketList *pktlist, void *readProcRefCon, void *srcConnRefCon); | |||
#endif | |||
#endif | |||
}; | |||
#endif |
@@ -106,71 +106,58 @@ m_CVCount(0) | |||
} | |||
void ControllerPluginGUI::AddCV() | |||
{ | |||
CVGUI *NewCV = new CVGUI (m_CVCount, this, m_GUIColour); | |||
m_GUIVec.push_back(NewCV); | |||
m_MainPack->add(NewCV->m_SliderGroup); | |||
m_CVCount++; | |||
void ControllerPluginGUI::AddCV() { | |||
CVGUI *NewCV = new CVGUI (m_CVCount, this, m_GUIColour); | |||
m_GUIVec.push_back (NewCV); | |||
m_MainPack->add (NewCV->m_SliderGroup); | |||
m_CVCount++; | |||
} | |||
void ControllerPluginGUI::DeleteCV() | |||
{ | |||
vector<CVGUI*>::iterator i=m_GUIVec.end(); | |||
i--; | |||
m_MainPack->remove((*i)->m_SliderGroup); | |||
delete *i; | |||
m_GUIVec.erase(i); | |||
m_CVCount--; | |||
void ControllerPluginGUI::DeleteCV() { | |||
vector<CVGUI*>::iterator i=m_GUIVec.end(); | |||
i--; | |||
m_MainPack->remove ((*i)->m_SliderGroup); | |||
delete *i; | |||
m_GUIVec.erase (i); | |||
m_CVCount--; | |||
} | |||
void ControllerPluginGUI::Clear() | |||
{ | |||
for (vector<ControllerPluginGUI::CVGUI*>::iterator i=m_GUIVec.begin(); | |||
i!=m_GUIVec.end(); i++) | |||
{ | |||
m_MainPack->remove((*i)->m_SliderGroup); | |||
delete *i; | |||
} | |||
m_GUIVec.clear(); | |||
m_CVCount=0; | |||
void ControllerPluginGUI::Clear() { | |||
for (vector<ControllerPluginGUI::CVGUI*>::iterator i=m_GUIVec.begin(); i!=m_GUIVec.end(); i++) { | |||
m_MainPack->remove ((*i)->m_SliderGroup); | |||
delete *i; | |||
} | |||
m_GUIVec.clear(); | |||
m_CVCount = 0; | |||
} | |||
void ControllerPluginGUI::UpdateValues(SpiralPlugin *o) | |||
{ | |||
ControllerPlugin *Plugin = (ControllerPlugin *)o; | |||
int c; | |||
float min, max, val; | |||
string Title,Min,Max; | |||
char temp[64]; | |||
Clear(); | |||
c=Plugin->GetNum(); | |||
for (int n=0; n<c; n++) { | |||
AddCV(); | |||
m_GUIVec[n]->m_Title->value(Plugin->GetName(n).c_str()); | |||
min = Plugin->GetMin(n); | |||
max = Plugin->GetMax(n); | |||
sprintf(temp,"%.6f",min); | |||
m_GUIVec[n]->m_Min->value(temp); | |||
sprintf(temp,"%.6f",max); | |||
m_GUIVec[n]->m_Max->value(temp); | |||
// Scale and invert value to match slider range (0->1) | |||
float val = 1.0f - (Plugin->GetVal(n) - min) / (max - min); | |||
m_GUIVec[n]->m_Chan->value(val); | |||
} | |||
resize(x(), y(), c*60, h()); | |||
void ControllerPluginGUI::UpdateValues (SpiralPlugin *o) { | |||
ControllerPlugin *Plugin = (ControllerPlugin *)o; | |||
int c; | |||
float min, max, val; | |||
string Title, Min, Max; | |||
char temp[64]; | |||
Clear(); | |||
c=Plugin->GetNum(); | |||
for (int n=0; n<c; n++) { | |||
AddCV(); | |||
m_GUIVec[n]->m_Title->value (Plugin->GetName (n).c_str()); | |||
min = Plugin->GetMin (n); | |||
sprintf(temp, "%.6f", min); | |||
m_GUIVec[n]->m_Min->value (temp); | |||
max = Plugin->GetMax (n); | |||
sprintf (temp, "%.6f", max); | |||
m_GUIVec[n]->m_Max->value (temp); | |||
// Scale and/or invert value to match slider range (0->1) | |||
float val = 1.0f - (Plugin->GetVal(n) - min) / (max - min); | |||
m_GUIVec[n]->m_Chan->value (val); | |||
} | |||
Resize (c*60, h()); | |||
} | |||
inline void ControllerPluginGUI::cb_Title_i(Fl_Input* o, void* v) | |||
{ | |||
int num=*(int*)(v); | |||
char temp[256]; | |||
sprintf(temp,"%s",m_GUIVec[num]->m_Title->value()); | |||
m_GUICH->Set("Number",num); | |||
@@ -249,44 +236,58 @@ inline void ControllerPluginGUI::cb_Min_i(Fl_Input* o, void* v) | |||
void ControllerPluginGUI::cb_Min(Fl_Input* o, void* v) | |||
{ ((ControllerPluginGUI*)(o->parent()->user_data()))->cb_Min_i(o,v);} | |||
inline void ControllerPluginGUI::cb_Add_i(Fl_Button* o, void* v) { | |||
if (m_CVCount<MAX_CHANNELS) { | |||
AddCV(); | |||
int num = (int)m_GUIVec.size(); | |||
float min = atof(m_GUIVec[num - 1]->m_Min->value()); | |||
float max = atof(m_GUIVec[num - 1]->m_Max->value()); | |||
float val = (1.0f-o->value())*(max-min)+min; | |||
char temp[256]; | |||
sprintf(temp,"%s",m_GUIVec[num - 1]->m_Title->value()); | |||
m_GUICH->Set("Number", num); | |||
m_GUICH->SetCommand(ControllerPlugin::SETNUM); | |||
m_GUICH->Wait(); | |||
m_GUICH->Set("Number", num); | |||
m_GUICH->SetData("Name",(void*)temp); | |||
m_GUICH->Set("Max",max); | |||
m_GUICH->Set("Value",val); | |||
m_GUICH->Set("Min",min); | |||
m_GUICH->SetCommand(ControllerPlugin::SETALL); | |||
m_GUICH->Wait(); | |||
resize(x(),y(),w()+60,h()); | |||
} | |||
inline void ControllerPluginGUI::cb_Add_i (Fl_Button* o, void* v) { | |||
if (m_CVCount < MAX_CHANNELS) { | |||
AddCV(); | |||
int num = (int)m_GUIVec.size(); | |||
float min = atof (m_GUIVec[num - 1]->m_Min->value()); | |||
float max = atof (m_GUIVec[num - 1]->m_Max->value()); | |||
float val = (1.0f-o->value()) * (max-min) + min; | |||
char temp[256]; | |||
sprintf (temp,"%s",m_GUIVec[num - 1]->m_Title->value()); | |||
m_GUICH->Set ("Number", num); | |||
m_GUICH->SetCommand (ControllerPlugin::SETNUM); | |||
m_GUICH->Wait (); | |||
m_GUICH->Set ("Number", num); | |||
m_GUICH->SetData ("Name", (void*)temp); | |||
m_GUICH->Set ("Max", max); | |||
m_GUICH->Set ("Value", val); | |||
m_GUICH->Set ("Min", min); | |||
m_GUICH->SetCommand (ControllerPlugin::SETALL); | |||
m_GUICH->Wait(); | |||
Resize (w()+60, h()); | |||
} | |||
} | |||
void ControllerPluginGUI::cb_Add(Fl_Button* o, void* v) | |||
{ ((ControllerPluginGUI*)(o->parent()->parent()))->cb_Add_i(o,v);} | |||
inline void ControllerPluginGUI::cb_Delete_i(Fl_Button* o, void* v) { | |||
if (m_GUIVec.size()>1) { | |||
DeleteCV(); | |||
m_GUICH->Set("Number",(int)m_GUIVec.size()); | |||
m_GUICH->SetCommand(ControllerPlugin::SETNUM); | |||
m_GUICH->Wait(); | |||
resize(x(),y(),w()-60,h()); | |||
} | |||
void ControllerPluginGUI::cb_Add (Fl_Button* o, void* v) { | |||
((ControllerPluginGUI*)(o->parent()->parent()))->cb_Add_i (o, v); | |||
} | |||
void ControllerPluginGUI::cb_Delete(Fl_Button* o, void* v) | |||
{ ((ControllerPluginGUI*)(o->parent()->parent()))->cb_Delete_i(o,v);} | |||
inline void ControllerPluginGUI::cb_Delete_i (Fl_Button* o, void* v) { | |||
if (m_GUIVec.size()>1) { | |||
DeleteCV(); | |||
m_GUICH->Set ("Number", (int)m_GUIVec.size()); | |||
m_GUICH->SetCommand (ControllerPlugin::SETNUM); | |||
m_GUICH->Wait(); | |||
Resize (w()-60, h()); | |||
} | |||
} | |||
void ControllerPluginGUI::cb_Delete (Fl_Button* o, void* v) { | |||
((ControllerPluginGUI*)(o->parent()->parent()))->cb_Delete_i (o, v); | |||
} | |||
const string ControllerPluginGUI::GetHelpText(const string &loc){ | |||
return string("") | |||
+ "This is a simple plugin to allow you to generate CV values\n" | |||
+ "interatively with sliders in the plugin window. Useful if you\n" | |||
+ "can't use Midi, or for controlling LADSPA plugins. The slider\n" | |||
+ "ranges can be set, and titles can be given to each slider.\n" | |||
+ "You can add or delete sliders from the plugin using the\n" | |||
+ "+ or - buttons.\n"; | |||
} | |||
/* | |||
// call for version <3 | |||
istream &operator>>(istream &s, ControllerPluginGUI &o) | |||
{ | |||
@@ -307,11 +308,11 @@ istream &operator>>(istream &s, ControllerPluginGUI &o) | |||
o.m_GUIVec[n]->m_Chan->value(Val); | |||
} | |||
o.resize(o.x(),o.y(),c*60,o.h()); | |||
o.resize (o.x(), o.y(), c*60, o.h()); | |||
return s; | |||
} | |||
// call for version >=3 | |||
// another version of the stream to fix the old style string streaming problem | |||
void ControllerPluginGUI::StreamIn(istream &s) | |||
@@ -358,13 +359,4 @@ void ControllerPluginGUI::StreamOut(ostream &s) | |||
s<<(*i)->m_Chan->value()<<endl; | |||
} | |||
} | |||
const string ControllerPluginGUI::GetHelpText(const string &loc){ | |||
return string("") | |||
+ "This is a simple plugin to allow you to generate CV values\n" | |||
+ "interatively with sliders in the plugin window. Useful if you\n" | |||
+ "can't use Midi, or for controlling LADSPA plugins. The slider\n" | |||
+ "ranges can be set, and titles can be given to each slider.\n" | |||
+ "You can add or delete sliders from the plugin using the\n" | |||
+ "+ or - buttons.\n"; | |||
} | |||
*/ |
@@ -31,63 +31,47 @@ | |||
static int Numbers[MAX_CHANNELS]; | |||
class ControllerPluginGUI : public SpiralPluginGUI | |||
{ | |||
public: | |||
ControllerPluginGUI(int w, int h, ControllerPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||
virtual void UpdateValues(SpiralPlugin *o); | |||
void StreamIn(std::istream &s); | |||
void StreamOut(std::ostream &s); | |||
protected: | |||
const std::string GetHelpText(const std::string &loc); | |||
private: | |||
void Clear(); | |||
Fl_Color m_GUIColour; | |||
class CVGUI | |||
{ | |||
public: | |||
CVGUI::CVGUI(int n, ControllerPluginGUI *p, Fl_Color SelColour); | |||
Fl_Group *m_SliderGroup; | |||
Fl_Input *m_Title; | |||
Fl_Input *m_Min; | |||
Fl_Input *m_Max; | |||
Fl_Slider *m_Chan; | |||
}; | |||
friend class CVGUI; | |||
Fl_Pack *m_MainPack, *m_Buttons; | |||
Fl_Button *m_Add, *m_Delete; | |||
std::vector<CVGUI*> m_GUIVec; | |||
void AddCV(); | |||
void DeleteCV(); | |||
int m_CVCount; | |||
//// Callbacks //// | |||
inline void cb_Title_i(Fl_Input* o, void* v); | |||
static void cb_Title(Fl_Input* o, void* v); | |||
inline void cb_Max_i(Fl_Input* o, void* v); | |||
static void cb_Max(Fl_Input* o, void* v); | |||
inline void cb_Chan_i(Fl_Slider* o, void* v); | |||
static void cb_Chan(Fl_Slider* o, void* v); | |||
inline void cb_Min_i(Fl_Input* o, void* v); | |||
static void cb_Min(Fl_Input* o, void* v); | |||
inline void cb_Add_i(Fl_Button* o, void* v); | |||
static void cb_Add(Fl_Button* o, void* v); | |||
inline void cb_Delete_i(Fl_Button* o, void* v); | |||
static void cb_Delete(Fl_Button* o, void* v); | |||
friend std::istream &operator>>(std::istream &s, ControllerPluginGUI &o); | |||
class ControllerPluginGUI : public SpiralPluginGUI { | |||
public: | |||
ControllerPluginGUI(int w, int h, ControllerPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||
virtual void UpdateValues(SpiralPlugin *o); | |||
// void StreamIn(std::istream &s); | |||
// void StreamOut(std::ostream &s); | |||
protected: | |||
const std::string GetHelpText(const std::string &loc); | |||
private: | |||
void Clear(); | |||
Fl_Color m_GUIColour; | |||
class CVGUI { | |||
public: | |||
CVGUI::CVGUI(int n, ControllerPluginGUI *p, Fl_Color SelColour); | |||
Fl_Group *m_SliderGroup; | |||
Fl_Input *m_Title, *m_Min, *m_Max; | |||
Fl_Slider *m_Chan; | |||
}; | |||
friend class CVGUI; | |||
Fl_Pack *m_MainPack, *m_Buttons; | |||
Fl_Button *m_Add, *m_Delete; | |||
std::vector<CVGUI*> m_GUIVec; | |||
void AddCV(); | |||
void DeleteCV(); | |||
int m_CVCount; | |||
//// Callbacks //// | |||
inline void cb_Title_i(Fl_Input* o, void* v); | |||
static void cb_Title(Fl_Input* o, void* v); | |||
inline void cb_Max_i(Fl_Input* o, void* v); | |||
static void cb_Max(Fl_Input* o, void* v); | |||
inline void cb_Chan_i(Fl_Slider* o, void* v); | |||
static void cb_Chan(Fl_Slider* o, void* v); | |||
inline void cb_Min_i(Fl_Input* o, void* v); | |||
static void cb_Min(Fl_Input* o, void* v); | |||
inline void cb_Add_i(Fl_Button* o, void* v); | |||
static void cb_Add(Fl_Button* o, void* v); | |||
inline void cb_Delete_i(Fl_Button* o, void* v); | |||
static void cb_Delete(Fl_Button* o, void* v); | |||
// friend std::istream &operator>>(std::istream &s, ControllerPluginGUI &o); | |||
}; | |||
std::istream &operator>>(std::istream &s, ControllerPluginGUI &o); | |||
// std::istream &operator>>(std::istream &s, ControllerPluginGUI &o); | |||
#endif |
@@ -284,8 +284,6 @@ void LADSPAPluginGUI::Update(void) | |||
m_BSlider->resize(x()+60, y()+15, 50, 20); | |||
m_BSetup->resize(x() + w() - 55, y()+15, 50, 20); | |||
} | |||
// Andy Preston bodged this bit in - might be better somewhere else | |||
DoResizeCallback (); | |||
} | |||
// This lot is only done on patch load | |||
@@ -513,7 +511,7 @@ void LADSPAPluginGUI::SetPage(int index) | |||
m_SliderGroup->hide(); | |||
m_SetupGroup->show(); | |||
resize(x(), y(), 500, 320); | |||
Resize(500, 320); | |||
m_KnobGroup->resize(x()+5, y()+35, w()-10, h()-40); | |||
m_SliderGroup->resize(x()+5, y()+35, w()-10, h()-40); | |||
@@ -524,8 +522,6 @@ void LADSPAPluginGUI::SetPage(int index) | |||
m_BKnob->resize(x()+5, y()+15, 50, 20); | |||
m_BSlider->resize(x()+60, y()+15, 50, 20); | |||
m_BSetup->resize(x() + w() - 55, y()+15, 50, 20); | |||
// Andy Preston bodged this bit in - might be better somewhere else | |||
DoResizeCallback (); | |||
} | |||
void LADSPAPluginGUI::SetUniqueID(unsigned long n) | |||
@@ -769,7 +765,7 @@ void LADSPAPluginGUI::UpdateKnobs(void) | |||
height = 45+rows*80; | |||
width = width < 170 ? 170 : width; | |||
} | |||
resize(x(), y(), width, height); | |||
Resize (width, height); | |||
// Resize all groups to fit | |||
m_KnobGroup->resize(x()+5, y()+35, w()-10, h()-40); | |||
@@ -817,8 +813,6 @@ void LADSPAPluginGUI::UpdateKnobs(void) | |||
m_KnobLabels[p]->hide(); | |||
} | |||
} | |||
// Andy Preston bodged this bit in - might be better somewhere else | |||
DoResizeCallback (); | |||
} | |||
// Rearrange sliders depending on connections | |||
@@ -882,7 +876,7 @@ void LADSPAPluginGUI::UpdateSliders(void) | |||
height = 45+rows*140; | |||
width = width < 170 ? 170 : width; | |||
} | |||
resize(x(), y(), width, height); | |||
Resize (width, height); | |||
// Resize all groups to fit | |||
m_KnobGroup->resize(x()+5, y()+35, w()-10, h()-40); | |||
@@ -925,8 +919,6 @@ void LADSPAPluginGUI::UpdateSliders(void) | |||
m_SliderLabels[p]->hide(); | |||
} | |||
} | |||
// Andy Preston bodged this bit in - might be better somewhere else | |||
DoResizeCallback (); | |||
} | |||
// Set value of slider and/or knob (both use the same settings) | |||
@@ -1152,7 +1144,8 @@ inline void LADSPAPluginGUI::cb_Select_i(Fl_Choice* o) | |||
m_GUICH->Wait(); | |||
} | |||
SelectPlugin(); | |||
DoResizeCallback (); | |||
// Make sure GUI frame can fit all the ports | |||
Resize (w(), h()); | |||
} | |||
void LADSPAPluginGUI::cb_Select(Fl_Choice* o) | |||
{ // Group GUI | |||
@@ -136,7 +136,7 @@ inline void LogicPluginGUI::cb_Inputs_i (Fl_Counter* o, void* v) { | |||
m_GUICH->Set ("Inputs", int (o->value ())); | |||
m_GUICH->SetCommand (LogicPlugin::SETINPUTS); | |||
m_GUICH->Wait (); | |||
DoResizeCallback (); | |||
Resize (w(), h()); | |||
} | |||
} | |||
@@ -96,7 +96,7 @@ m_CurrentNote(0) | |||
MidiPlugin::~MidiPlugin() | |||
{ | |||
m_RefCount--; | |||
m_RefCount--; | |||
if (m_RefCount==0) MidiDevice::PackUpAndGoHome(); | |||
} | |||
@@ -128,17 +128,17 @@ inline void MidiPluginGUI::cb_DeviceNum_i(Fl_Counter* o, void* v) | |||
m_GUICH->Set("DeviceNum",(int)o->value()-1); | |||
} | |||
void MidiPluginGUI::cb_DeviceNum(Fl_Counter* o, void* v) | |||
void MidiPluginGUI::cb_DeviceNum(Fl_Counter* o, void* v) | |||
{ ((MidiPluginGUI*)(o->parent()))->cb_DeviceNum_i(o,v);} | |||
inline void MidiPluginGUI::cb_NoteCut_i(Fl_Button* o, void* v) | |||
inline void MidiPluginGUI::cb_NoteCut_i(Fl_Button* o, void* v) | |||
{ m_GUICH->Set("NoteCut",o->value()); } | |||
void MidiPluginGUI::cb_NoteCut(Fl_Button* o, void* v) | |||
void MidiPluginGUI::cb_NoteCut(Fl_Button* o, void* v) | |||
{ ((MidiPluginGUI*)(o->parent()))->cb_NoteCut_i(o,v);} | |||
inline void MidiPluginGUI::cb_ContinuousNotes_i(Fl_Button* o, void* v) | |||
inline void MidiPluginGUI::cb_ContinuousNotes_i(Fl_Button* o, void* v) | |||
{ m_GUICH->Set("ContinuousNotes",o->value()); } | |||
void MidiPluginGUI::cb_ContinuousNotes(Fl_Button* o, void* v) | |||
void MidiPluginGUI::cb_ContinuousNotes(Fl_Button* o, void* v) | |||
{ ((MidiPluginGUI*)(o->parent()))->cb_ContinuousNotes_i(o,v);} | |||
inline void MidiPluginGUI::cb_AddControl_i(Fl_Button* o, void* v) | |||
@@ -148,67 +148,67 @@ inline void MidiPluginGUI::cb_AddControl_i(Fl_Button* o, void* v) | |||
List.push_back("0 Bank Select"); | |||
List.push_back("1 Modulation Wheel (coarse)"); | |||
List.push_back("2 Breath controller (coarse)"); | |||
List.push_back("3 None"); | |||
List.push_back("3 None"); | |||
List.push_back("4 Foot Pedal (coarse)"); | |||
List.push_back("5 Portamento Time (coarse)"); | |||
List.push_back("6 Data Entry (coarse)"); | |||
List.push_back("7 Volume (coarse)"); | |||
List.push_back("8 Balance (coarse)"); | |||
List.push_back("9 None"); | |||
List.push_back("9 None"); | |||
List.push_back("10 Pan position (coarse)"); | |||
List.push_back("11 Expression (coarse)"); | |||
List.push_back("12 Effect Control 1 (coarse)"); | |||
List.push_back("13 Effect Control 2 (coarse)"); | |||
List.push_back("14 None"); | |||
List.push_back("15 None"); | |||
List.push_back("14 None"); | |||
List.push_back("15 None"); | |||
List.push_back("16 General Purpose Slider 1"); | |||
List.push_back("17 General Purpose Slider 2"); | |||
List.push_back("18 General Purpose Slider 3"); | |||
List.push_back("19 General Purpose Slider 4"); | |||
List.push_back("20 None"); | |||
List.push_back("21 None"); | |||
List.push_back("22 None"); | |||
List.push_back("23 None"); | |||
List.push_back("24 None"); | |||
List.push_back("25 None"); | |||
List.push_back("26 None"); | |||
List.push_back("27 None"); | |||
List.push_back("28 None"); | |||
List.push_back("29 None"); | |||
List.push_back("30 None"); | |||
List.push_back("31 None"); | |||
List.push_back("20 None"); | |||
List.push_back("21 None"); | |||
List.push_back("22 None"); | |||
List.push_back("23 None"); | |||
List.push_back("24 None"); | |||
List.push_back("25 None"); | |||
List.push_back("26 None"); | |||
List.push_back("27 None"); | |||
List.push_back("28 None"); | |||
List.push_back("29 None"); | |||
List.push_back("30 None"); | |||
List.push_back("31 None"); | |||
List.push_back("32 Bank Select (fine)"); | |||
List.push_back("33 Modulation Wheel (fine)"); | |||
List.push_back("34 Breath controller (fine)"); | |||
List.push_back("35 None"); | |||
List.push_back("35 None"); | |||
List.push_back("36 Foot Pedal (fine)"); | |||
List.push_back("37 Portamento Time (fine)"); | |||
List.push_back("38 Data Entry (fine)"); | |||
List.push_back("39 Volume (fine)"); | |||
List.push_back("40 Balance (fine)"); | |||
List.push_back("41 None"); | |||
List.push_back("41 None"); | |||
List.push_back("42 Pan position (fine)"); | |||
List.push_back("43 Expression (fine)"); | |||
List.push_back("44 Effect Control 1 (fine)"); | |||
List.push_back("45 Effect Control 2 (fine)"); | |||
List.push_back("46 None"); | |||
List.push_back("47 None"); | |||
List.push_back("48 None"); | |||
List.push_back("49 None"); | |||
List.push_back("50 None"); | |||
List.push_back("51 None"); | |||
List.push_back("52 None"); | |||
List.push_back("53 None"); | |||
List.push_back("54 None"); | |||
List.push_back("55 None"); | |||
List.push_back("56 None"); | |||
List.push_back("57 None"); | |||
List.push_back("58 None"); | |||
List.push_back("59 None"); | |||
List.push_back("60 None"); | |||
List.push_back("61 None"); | |||
List.push_back("62 None"); | |||
List.push_back("63 None"); | |||
List.push_back("46 None"); | |||
List.push_back("47 None"); | |||
List.push_back("48 None"); | |||
List.push_back("49 None"); | |||
List.push_back("50 None"); | |||
List.push_back("51 None"); | |||
List.push_back("52 None"); | |||
List.push_back("53 None"); | |||
List.push_back("54 None"); | |||
List.push_back("55 None"); | |||
List.push_back("56 None"); | |||
List.push_back("57 None"); | |||
List.push_back("58 None"); | |||
List.push_back("59 None"); | |||
List.push_back("60 None"); | |||
List.push_back("61 None"); | |||
List.push_back("62 None"); | |||
List.push_back("63 None"); | |||
List.push_back("64 Hold Pedal (on/off)"); | |||
List.push_back("65 Portamento (on/off)"); | |||
List.push_back("66 Sustenuto Pedal (on/off)"); | |||
@@ -229,13 +229,13 @@ inline void MidiPluginGUI::cb_AddControl_i(Fl_Button* o, void* v) | |||
List.push_back("81 General Purpose Button 2 (on/off)"); | |||
List.push_back("82 General Purpose Button 3 (on/off)"); | |||
List.push_back("83 General Purpose Button 4 (on/off)"); | |||
List.push_back("84 None"); | |||
List.push_back("85 None"); | |||
List.push_back("86 None"); | |||
List.push_back("87 None"); | |||
List.push_back("88 None"); | |||
List.push_back("89 None"); | |||
List.push_back("90 None"); | |||
List.push_back("84 None"); | |||
List.push_back("85 None"); | |||
List.push_back("86 None"); | |||
List.push_back("87 None"); | |||
List.push_back("88 None"); | |||
List.push_back("89 None"); | |||
List.push_back("90 None"); | |||
List.push_back("91 Effects Level"); | |||
List.push_back("92 Tremulo Level"); | |||
List.push_back("93 Chorus Level"); | |||
@@ -247,11 +247,11 @@ inline void MidiPluginGUI::cb_AddControl_i(Fl_Button* o, void* v) | |||
List.push_back("99 Non-registered Parameter (coarse)"); | |||
List.push_back("100 Registered Parameter (fine)"); | |||
List.push_back("101 Registered Parameter (coarse)"); | |||
List.push_back("102 None"); | |||
List.push_back("103 None"); | |||
List.push_back("104 None"); | |||
List.push_back("105 None"); | |||
List.push_back("106 None"); | |||
List.push_back("102 None"); | |||
List.push_back("103 None"); | |||
List.push_back("104 None"); | |||
List.push_back("105 None"); | |||
List.push_back("106 None"); | |||
List.push_back("107 None"); | |||
List.push_back("108 None"); | |||
List.push_back("109 None"); | |||
@@ -283,21 +283,26 @@ inline void MidiPluginGUI::cb_AddControl_i(Fl_Button* o, void* v) | |||
m_GUICH->SetData("Name",Temp); | |||
m_GUICH->SetCommand(MidiPlugin::ADDCONTROL); | |||
m_GUICH->Wait (); | |||
DoResizeCallback (); | |||
// Make sure GUI frame can show all the ports | |||
Resize (w(), h()); | |||
//m_Plugin->AddControl(c,List[c]); | |||
} | |||
} | |||
void MidiPluginGUI::cb_AddControl(Fl_Button* o, void* v) | |||
{ ((MidiPluginGUI*)(o->parent()))->cb_AddControl_i(o,v);} | |||
inline void MidiPluginGUI::cb_RemoveControl_i(Fl_Button* o, void* v) | |||
{ | |||
m_GUICH->SetCommand(MidiPlugin::DELCONTROL); | |||
m_GUICH->Wait (); | |||
DoResizeCallback (); | |||
void MidiPluginGUI::cb_AddControl (Fl_Button* o, void* v) { | |||
((MidiPluginGUI*)(o->parent()))->cb_AddControl_i (o, v); | |||
} | |||
inline void MidiPluginGUI::cb_RemoveControl_i (Fl_Button* o, void* v) { | |||
m_GUICH->SetCommand(MidiPlugin::DELCONTROL); | |||
m_GUICH->Wait (); | |||
// Make sure GUI frame can show all the ports | |||
Resize (w(), h()); | |||
} | |||
void MidiPluginGUI::cb_RemoveControl (Fl_Button* o, void* v) { | |||
((MidiPluginGUI*)(o->parent()))->cb_RemoveControl_i (o, v); | |||
} | |||
void MidiPluginGUI::cb_RemoveControl(Fl_Button* o, void* v) | |||
{ ((MidiPluginGUI*)(o->parent()))->cb_RemoveControl_i(o,v);} | |||
const string MidiPluginGUI::GetHelpText(const string &loc){ | |||
return string("") | |||
@@ -59,7 +59,7 @@ inline void MixSwitchPluginGUI::cb_Chans_i (Fl_Counter* o, void* v) { | |||
m_GUICH->Set ("Chans", int (o->value ())); | |||
m_GUICH->SetCommand (MixSwitchPlugin::SETCHANS); | |||
m_GUICH->Wait (); | |||
DoResizeCallback (); | |||
Resize (w(), h()); | |||
} | |||
} | |||
@@ -83,9 +83,7 @@ void MixerPluginGUI::AddChan (bool SendData, bool ResizeIt) { | |||
m_GUICH->SetCommand(MixerPlugin::SETCH); | |||
m_GUICH->Wait (); | |||
} | |||
if (ResizeIt && num > 3) { | |||
resize (x(), y(), w()+20, h()); | |||
} | |||
if (ResizeIt && num > 3) Resize (w()+20, h()); | |||
} | |||
void MixerPluginGUI::DeleteChan (bool SendData) { | |||
@@ -100,9 +98,7 @@ void MixerPluginGUI::DeleteChan (bool SendData) { | |||
m_GUICH->SetCommand (MixerPlugin::SETNUM); | |||
m_GUICH->Wait (); | |||
} | |||
if (num > 2) { | |||
resize (x(), y(), w()-20, h()); | |||
} | |||
if (num > 2) Resize (w()-20, h()); | |||
} | |||
void MixerPluginGUI::UpdateValues(SpiralPlugin *o) { | |||
@@ -63,10 +63,10 @@ SpiralPluginGUI::~SpiralPluginGUI() | |||
Fl::check(); | |||
} | |||
void SpiralPluginGUI::resize (int newx, int newy, int neww, int newh) { | |||
void SpiralPluginGUI::Resize (int neww, int newh) { | |||
resize (x(), y(), neww, newh); | |||
m_Help->position (x()+neww-11, y()+2); | |||
SpiralGUIType::resize (newx, newy, neww, newh); | |||
//DoResizeCallback (); | |||
DoResizeCallback (); | |||
} | |||
void SpiralPluginGUI::Update() | |||
@@ -32,10 +32,9 @@ class SpiralPluginGUI : public SpiralGUIType { | |||
public: | |||
SpiralPluginGUI (int w, int h, SpiralPlugin* o, ChannelHandler *ch); | |||
~SpiralPluginGUI (); | |||
virtual void resize (int x, int y, int w, int h); | |||
void Resize (int neww, int newh); | |||
virtual void Update (); | |||
// called while audio thread is suspended, so direct access to the | |||
// spiralplugin is acceptable | |||
// called while audio thread is suspended, so direct access to the spiralplugin is acceptable | |||
virtual void UpdateValues (SpiralPlugin *o) = 0; | |||
protected: | |||
ChannelHandler *m_GUICH; | |||
@@ -59,7 +59,7 @@ inline void SplitSwitchPluginGUI::cb_Chans_i (Fl_Counter* o, void* v) { | |||
m_GUICH->Set ("Chans", int (o->value ())); | |||
m_GUICH->SetCommand (SplitSwitchPlugin::SETCHANS); | |||
m_GUICH->Wait (); | |||
DoResizeCallback (); | |||
Resize (w(), h()); | |||
} | |||
} | |||