mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Added MIDI input port, loopers get fed MIDI data
This commit is contained in:
parent
7473e8d215
commit
6e861dd4c1
5 changed files with 41 additions and 2 deletions
|
@ -13,10 +13,12 @@ class Buffers
|
|||
memset( audio, 0, sizeof(float*)*2);
|
||||
}
|
||||
float* audio[2];
|
||||
char* midi [1];
|
||||
|
||||
enum BUFFER {
|
||||
MASTER_OUTPUT = 0,
|
||||
MASTER_INPUT,
|
||||
MASTER_MIDI_INPUT,
|
||||
};
|
||||
|
||||
// Jack details
|
||||
|
|
30
src/jack.cxx
30
src/jack.cxx
|
@ -32,6 +32,12 @@ Jack::Jack()
|
|||
JackPortIsInput,
|
||||
0 );
|
||||
|
||||
masterMidiInput = jack_port_register( client,
|
||||
"midi_in",
|
||||
JACK_DEFAULT_MIDI_TYPE,
|
||||
JackPortIsInput,
|
||||
0 );
|
||||
|
||||
if ( jack_set_process_callback( client,
|
||||
static_process,
|
||||
static_cast<void*>(this)) )
|
||||
|
@ -71,8 +77,28 @@ int Jack::process (jack_nframes_t nframes)
|
|||
handleDspEvents();
|
||||
|
||||
// get buffers
|
||||
buffers.audio[Buffers::MASTER_INPUT] = (float*)jack_port_get_buffer( masterInput , nframes);
|
||||
buffers.audio[Buffers::MASTER_OUTPUT] = (float*)jack_port_get_buffer( masterOutput, nframes);
|
||||
buffers.audio[Buffers::MASTER_INPUT] = (float*)jack_port_get_buffer( masterInput , nframes);
|
||||
buffers.audio[Buffers::MASTER_OUTPUT] = (float*)jack_port_get_buffer( masterOutput, nframes);
|
||||
buffers.midi[Buffers::MASTER_MIDI_INPUT]= (char*) jack_port_get_buffer( masterMidiInput, nframes );
|
||||
|
||||
// process incoming MIDI
|
||||
jack_midi_event_t in_event;
|
||||
|
||||
int masterMidiInputIndex = 0;
|
||||
int event_count = (int) jack_midi_get_event_count( buffers.midi[Buffers::MASTER_MIDI_INPUT] );
|
||||
|
||||
while ( masterMidiInputIndex < event_count )
|
||||
{
|
||||
jack_midi_event_get(&in_event, buffers.midi[Buffers::MASTER_MIDI_INPUT], masterMidiInputIndex);
|
||||
|
||||
cout << int(in_event.buffer[0]) << int(in_event.buffer[1]) << int(in_event.buffer[2]) << endl;
|
||||
|
||||
// check each looper for MIDI match
|
||||
for(int i = 0; i < loopers.size(); i++)
|
||||
loopers.at(i)->midi( (char*)in_event.buffer );
|
||||
|
||||
masterMidiInputIndex++;
|
||||
}
|
||||
|
||||
// pre-zero output buffers
|
||||
memset( buffers.audio[Buffers::MASTER_OUTPUT], 0, sizeof(float) * nframes );
|
||||
|
|
|
@ -61,6 +61,8 @@ class Jack
|
|||
jack_port_t* masterInput;
|
||||
jack_port_t* masterOutput;
|
||||
|
||||
jack_port_t* masterMidiInput;
|
||||
|
||||
// JACK callbacks
|
||||
int process (jack_nframes_t);
|
||||
|
||||
|
|
|
@ -37,6 +37,11 @@ Looper::Looper(int t) :
|
|||
fRec0[i] = 0;
|
||||
}
|
||||
|
||||
void Looper::midi(char* data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Looper::setState(State s)
|
||||
{
|
||||
if ( state == STATE_RECORDING )
|
||||
|
@ -68,11 +73,13 @@ void Looper::process(int nframes, Buffers* buffers)
|
|||
|
||||
if (track == 0)
|
||||
{
|
||||
/*
|
||||
// log pitch-shift rates
|
||||
char buffer [50];
|
||||
sprintf (buffer, "Looper, pbs=%f, dP=%f", playbackSpeed, deltaPitch );
|
||||
EventGuiPrint e( buffer );
|
||||
writeToGuiRingbuffer( &e );
|
||||
*/
|
||||
}
|
||||
|
||||
if ( state == STATE_PLAYING )
|
||||
|
|
|
@ -24,6 +24,8 @@ class Looper : public Observer // for notifications
|
|||
|
||||
Looper(int t);
|
||||
|
||||
void midi(char* data);
|
||||
|
||||
void bar();
|
||||
void beat();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue