void SoftSynthAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    MidiBuffer processedMidi;
    int time;
    MidiMessage m;
    
    for (MidiBuffer::Iterator i(midiMessages); i.getNextEvent(m, time);) {
        if (m.isNoteOn()) {
            m = MidiMessage::noteOn(m.getChannel(), m.getNoteNumber(), m.getVelocity());
            synth.keyPressed(m.getNoteNumber(), m.getVelocity());
        } else if (m.isNoteOff()) {
            m = MidiMessage::noteOff(m.getChannel(), m.getNoteNumber(), m.getVelocity());
            synth.keyReleased(m.getNoteNumber());
        }
        
        processedMidi.addEvent(m, time);
    }
    
    auto synthBuffer = synth.getNextBuffer(buffer.getNumSamples());
    float *leftData = buffer.getWritePointer(0);
    float *rightData = buffer.getWritePointer(1);
    for (int i = 0; i < buffer.getNumSamples(); ++i) {
        leftData[i] = synthBuffer[i];
        rightData[i] = synthBuffer[i];
    }
    
    midiMessages.swapWith(processedMidi);
}
Example #2
0
static void RT_MIDI_send_msg_to_patch(struct Patch *patch, MidiMessage message, int64_t seq_time){       
  if (message.isNoteOn())
    RT_PATCH_play_note(patch, message.getNoteNumber(), -1, message.getVelocity() / 127.0f, 0.0f, seq_time);
  
  else if (message.isNoteOff())
    RT_PATCH_stop_note(patch, message.getNoteNumber(), -1, seq_time);
  
  else if (message.isAftertouch())
    RT_PATCH_change_velocity(patch, message.getNoteNumber(), -1, message.getChannelPressureValue() / 127.0f, seq_time);

  else {
    
    const uint8_t *raw_data = message.getRawData();
    int len = message.getRawDataSize();

    R_ASSERT_RETURN_IF_FALSE(len>=1 && len<=3);

    uint32_t msg;

    if (len==3)
      msg = MIDI_msg_pack3(raw_data[0],raw_data[1],raw_data[2]);
    else if (len==2)
      msg = MIDI_msg_pack2(raw_data[0],raw_data[1]);
    else if (len==1)
      msg = MIDI_msg_pack1(raw_data[0]);
    else
      return;
    
    RT_PATCH_send_raw_midi_message(patch, msg, seq_time);
  }
}
Example #3
0
void Synthesiser::handleMidiEvent (const MidiMessage& m)
{
    if (m.isNoteOn())
    {
        noteOn (m.getChannel(),
                m.getNoteNumber(),
                m.getFloatVelocity());
    }
    else if (m.isNoteOff())
    {
        noteOff (m.getChannel(),
                 m.getNoteNumber(),
                 true);
    }
    else if (m.isAllNotesOff() || m.isAllSoundOff())
    {
        allNotesOff (m.getChannel(), true);
    }
    else if (m.isPitchWheel())
    {
        const int channel = m.getChannel();
        const int wheelPos = m.getPitchWheelValue();
        lastPitchWheelValues [channel - 1] = wheelPos;

        handlePitchWheel (channel, wheelPos);
    }
    else if (m.isController())
    {
        handleController (m.getChannel(),
                          m.getControllerNumber(),
                          m.getControllerValue());
    }
}
Example #4
0
const CtrlrMidiMessageType midiMessageToType (const MidiMessage &midiMessage)
{
	if (midiMessage.isController())
	{
		return (CC);
	}
	else if (midiMessage.isSysEx())
	{
		return (SysEx);
	}
	else if (midiMessage.isNoteOn())
	{
		return (NoteOn);
	}
	else if (midiMessage.isNoteOff())
	{
		return (NoteOff);
	}
	else if (midiMessage.isAftertouch())
	{
		return (Aftertouch);
	}
	else if (midiMessage.isChannelPressure())
	{
		return (ChannelPressure);
	}
	else if (midiMessage.isProgramChange())
	{
		return (ProgramChange);
	}
	else if (midiMessage.isPitchWheel())
	{
		return (PitchWheel);
	}
	else if (midiMessage.isMidiClock())
	{
		return (MidiClock);
	}
	else if (midiMessage.isMidiContinue())
	{
		return (MidiClockContinue);
	}
	else if (midiMessage.isMidiStart())
	{
		return (MidiClockStart);
	}
	else if (midiMessage.isMidiStop())
	{
		return (MidiClockStop);
	}
	else if (midiMessage.isActiveSense())
	{
		return (ActiveSense);
	}
	return (SysEx);
}
Example #5
0
void MIDIInputDevice::handleIncomingMidiMessage(MidiInput * source, const MidiMessage & message)
{
	if (source != device)
	{
		DBG("different device");
		return;
	}

	if (message.isNoteOn()) inputListeners.call(&MIDIInputListener::noteOnReceived, message.getChannel(), message.getNoteNumber(), message.getVelocity());
	else if(message.isNoteOff()) inputListeners.call(&MIDIInputListener::noteOffReceived, message.getChannel(), message.getNoteNumber(), 0); //force note off to velocity 0
	else if(message.isController()) inputListeners.call(&MIDIInputListener::controlChangeReceived, message.getChannel(), message.getControllerNumber(), message.getControllerValue());
	else if(message.isSysEx()) inputListeners.call(&MIDIInputListener::sysExReceived, message);
}
void MidiKeyboardState::processNextMidiEvent (const MidiMessage& message)
{
    if (message.isNoteOn())
    {
        noteOnInternal (message.getChannel(), message.getNoteNumber(), message.getFloatVelocity());
    }
    else if (message.isNoteOff())
    {
        noteOffInternal (message.getChannel(), message.getNoteNumber(), message.getFloatVelocity());
    }
    else if (message.isAllNotesOff())
    {
        for (int i = 0; i < 128; ++i)
            noteOffInternal (message.getChannel(), i, 0.0f);
    }
}
Example #7
0
static PyObject *
PyMidiMessage_str(PyObject *self) {
  MidiMessage *m = ((PyMidiMessage*)self)->m;
  static char s[256];
  if(m->isNoteOn()) {
    sprintf(s, "<NOTE ON, note: %d (%s), velocity: %d, channel: %d>",
            m->getNoteNumber(),
            m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
            m->getVelocity(),
            m->getChannel());
  } else if(m->isNoteOff()) {
    sprintf(s, "<NOTE OFF, note: %d (%s), channel: %d>",
            m->getNoteNumber(),
            m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
            m->getChannel());
  } else if(m->isProgramChange()) {
    sprintf(s, "<PROGRAM CHANGE: program: %d, channel: %d>", m->getProgramChangeNumber(), m->getChannel());
  } else if(m->isPitchWheel()) {
    sprintf(s, "<PITCH WHEEL: value: %d, channel: %d>", m->getPitchWheelValue(), m->getChannel());
  } else if(m->isAftertouch()) {
    sprintf(s, "<AFTERTOUCH: note: %d (%s) value: %d, channel: %d>",
            m->getNoteNumber(),
            m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
            m->getAfterTouchValue(),
            m->getChannel());
  } else if(m->isChannelPressure()) {
    sprintf(s, "<CHANNEL PRESSURE: pressure: %d, channel: %d>", m->getChannelPressureValue(), m->getChannel());
  } else if(m->isController()) {
    const char *name = m->getControllerName(m->getControllerNumber());
    if(strlen(name) > 0) {
      sprintf(s, "<CONTROLLER: %d (\"%s\"), value: %d, channel: %d>",
              m->getControllerNumber(),
              m->getControllerName(m->getControllerNumber()),
              m->getControllerValue(),
              m->getChannel());
    } else {
      sprintf(s, "<CONTROLLER: %d, value: %d, channel: %d>",
              m->getControllerNumber(),
              m->getControllerValue(),
              m->getChannel());
    }
  } else {
    sprintf(s, "<MidiMessage (misc type)>");
  }

  return PK_STRING(s);
}
Example #8
0
void MidiManager::processMidiMessage(const MidiMessage& midi_message, int sample_position) {
  if (midi_message.isProgramChange()) {
    current_patch_ = midi_message.getProgramChangeNumber();
    File patch = LoadSave::loadPatch(current_bank_, current_folder_, current_patch_,
                                     synth_, *gui_state_);
    PatchLoadedCallback* callback = new PatchLoadedCallback(listener_, patch);
    callback->post();
    return;
  }

  if (midi_message.isNoteOn()) {
    engine_->noteOn(midi_message.getNoteNumber(),
                    midi_message.getVelocity() / (mopo::MIDI_SIZE - 1.0),
                    0, midi_message.getChannel() - 1);
  }
  else if (midi_message.isNoteOff())
    engine_->noteOff(midi_message.getNoteNumber());
  else if (midi_message.isAllNotesOff())
    engine_->allNotesOff();
  else if (midi_message.isSustainPedalOn())
    engine_->sustainOn();
  else if (midi_message.isSustainPedalOff())
    engine_->sustainOff();
  else if (midi_message.isAftertouch()) {
    mopo::mopo_float note = midi_message.getNoteNumber();
    mopo::mopo_float value = (1.0 * midi_message.getAfterTouchValue()) / mopo::MIDI_SIZE;
    engine_->setAftertouch(note, value);
  }
  else if (midi_message.isPitchWheel()) {
    double percent = (1.0 * midi_message.getPitchWheelValue()) / PITCH_WHEEL_RESOLUTION;
    double value = 2 * percent - 1.0;
    engine_->setPitchWheel(value, midi_message.getChannel());
  }
  else if (midi_message.isController()) {
    int controller_number = midi_message.getControllerNumber();
    if (controller_number == MOD_WHEEL_CONTROL_NUMBER) {
      double percent = (1.0 * midi_message.getControllerValue()) / MOD_WHEEL_RESOLUTION;
      engine_->setModWheel(percent, midi_message.getChannel());
    }
    else if (controller_number == BANK_SELECT_NUMBER)
      current_bank_ = midi_message.getControllerValue();
    else if (controller_number == FOLDER_SELECT_NUMBER)
      current_folder_ = midi_message.getControllerValue();
    midiInput(midi_message.getControllerNumber(), midi_message.getControllerValue());
  }
}
Example #9
0
/** This function is called whenever the Seaboard object receives some Midi data from the physical Seaboard. It sends out the relevant midi message to all of its listeners, who in return overwrite the midi message functions in order to implement the desired response behaviour.*/
void Seaboard::handleIncomingMidiMessage(MidiInput *source, const MidiMessage &message)
{
	if (message.isNoteOn())
	{
		listeners.call(&Seaboard::Listener::seaboardDidGetNoteOn,message);
	}
	else if (message.isNoteOff())
	{
		listeners.call(&Seaboard::Listener::seaboardDidGetNoteOff,message);
	}
	else if (message.isAftertouch())
	{
		listeners.call(&Seaboard::Listener::seaboardDidGetAftertouch,message);
	}
	else if (message.isPitchWheel())
	{
		listeners.call(&Seaboard::Listener::seaboardDidGetPitchBend,message);
	}
	listeners.call(&Seaboard::Listener::seaboardDidGetMessage,message);
}
Example #10
0
void Tunefish4AudioProcessor::processEvents(MidiBuffer &midiMessages, eU32 messageOffset, eU32 frameSize)
{
    MidiBuffer::Iterator it(midiMessages);
    MidiMessage midiMessage;
    int samplePosition;

    it.setNextSamplePosition(messageOffset);

    while (it.getNextEvent(midiMessage, samplePosition))
    {
        if (samplePosition >= messageOffset + frameSize)
            break;

        if (midiMessage.isNoteOn())
        {
            eU8 velocity = midiMessage.getVelocity();
            eU8 note = midiMessage.getNoteNumber();

            eTfInstrumentNoteOn(*tf, note, velocity);
        }
        else if (midiMessage.isNoteOff())
        {
            eU8 note = midiMessage.getNoteNumber();

            eTfInstrumentNoteOff(*tf, note);
        }
        else if (midiMessage.isAllNotesOff())
        {
            eTfInstrumentAllNotesOff(*tf);
        }
        else if (midiMessage.isPitchWheel())
        {
            eS32 bend_lsb = midiMessage.getRawData()[1] & 0x7f;
            eS32 bend_msb = midiMessage.getRawData()[2] & 0x7f;

            eTfInstrumentPitchBend(*tf, ((eF32(bend_msb) / 127.0f) - 0.5f) * 2.0f,
                                   ((eF32(bend_lsb) / 127.0f) - 0.5f) * 2.0f);
        }
    }
}
Example #11
0
void Synthesiser::handleMidiEvent (const MidiMessage& m)
{
    const int channel = m.getChannel();

    if (m.isNoteOn())
    {
        noteOn (channel, m.getNoteNumber(), m.getFloatVelocity());
    }
    else if (m.isNoteOff())
    {
        noteOff (channel, m.getNoteNumber(), m.getFloatVelocity(), true);
    }
    else if (m.isAllNotesOff() || m.isAllSoundOff())
    {
        allNotesOff (channel, true);
    }
    else if (m.isPitchWheel())
    {
        const int wheelPos = m.getPitchWheelValue();
        lastPitchWheelValues [channel - 1] = wheelPos;
        handlePitchWheel (channel, wheelPos);
    }
    else if (m.isAftertouch())
    {
        handleAftertouch (channel, m.getNoteNumber(), m.getAfterTouchValue());
    }
    else if (m.isChannelPressure())
    {
        handleChannelPressure (channel, m.getChannelPressureValue());
    }
    else if (m.isController())
    {
        handleController (channel, m.getControllerNumber(), m.getControllerValue());
    }
    else if (m.isProgramChange())
    {
        handleProgramChange (channel, m.getProgramChangeNumber());
    }
}
Example #12
0
void LyrebirdAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    
    // Do Midi things
    buffer.clear();
    
    int time;
    MidiMessage m;
    
    for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (m, time);)
    {
        sawGenerator->setWavelength(currentSampleRate, m.getMidiNoteInHertz(m.getNoteNumber()));
        if (m.isNoteOff())
        {
            sawGenerator->setWavelength(currentSampleRate, 0);
        }
    }
    
    
    // In case we have more outputs than inputs, this code clears any output
    // channels that didn't contain input data, (because these aren't
    // guaranteed to be empty - they may contain garbage).
    // I've added this to avoid people getting screaming feedback
    // when they first compile the plugin, but obviously you don't need to
    // this code if your algorithm already fills all the output channels.
    for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
        buffer.clear (i, 0, buffer.getNumSamples());


    float* leftData = buffer.getWritePointer (0);
    float* rightData = buffer.getWritePointer(1);
    for (int sample = 0; sample < buffer.getNumSamples(); sample++)
    {
        leftData[sample] = sawGenerator->getCurrentAmplitude();
        rightData[sample] = sawGenerator->getCurrentAmplitude();
        sawGenerator->incrementSaw();
    }
}
String ZenMidiVisualiserComponent::getMidiMessageDescription(const MidiMessage& m)
{
	if (m.isNoteOn())           return "Note on: " + S(m.getNoteNumber()) + " (" + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ") Vel: " + S(m.getVelocity());
	if (m.isNoteOff())          return "Note off: " + S(m.getNoteNumber()) + " (" + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ")";
	if (m.isProgramChange())    return "Program change (Number): " + String(m.getProgramChangeNumber());
	if (m.isPitchWheel())       return "Pitch wheel: " + String(m.getPitchWheelValue());
	if (m.isAftertouch())       return "After touch: " + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ": " + String(m.getAfterTouchValue());
	if (m.isChannelPressure())  return "Channel pressure: " + String(m.getChannelPressureValue());
	if (m.isAllNotesOff())      return "All notes off";
	if (m.isAllSoundOff())      return "All sound off";
	if (m.isMetaEvent())        return "Meta event";

	if (m.isController())
	{
		String temp = MidiMessage::getControllerName(m.getControllerNumber());
		String name = "Controller [" + S(m.getControllerNumber()) + "]";
		if (!temp.isEmpty())
			name += " " + temp;

		return name + ": " + String(m.getControllerValue());
	}

	return String::toHexString(m.getRawData(), m.getRawDataSize());
}
Example #14
0
static String getMidiMessageDescription (const MidiMessage& m)
{
    if (m.isNoteOn())           return "Note on "  + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3);
    if (m.isNoteOff())          return "Note off " + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3);
    if (m.isProgramChange())    return "Program change " + String (m.getProgramChangeNumber());
    if (m.isPitchWheel())       return "Pitch wheel " + String (m.getPitchWheelValue());
    if (m.isAftertouch())       return "After touch " + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3) +  ": " + String (m.getAfterTouchValue());
    if (m.isChannelPressure())  return "Channel pressure " + String (m.getChannelPressureValue());
    if (m.isAllNotesOff())      return "All notes off";
    if (m.isAllSoundOff())      return "All sound off";
    if (m.isMetaEvent())        return "Meta event";

    if (m.isController())
    {
        String name (MidiMessage::getControllerName (m.getControllerNumber()));

        if (name.isEmpty())
            name = "[" + String (m.getControllerNumber()) + "]";

        return "Controler " + name + ": " + String (m.getControllerValue());
    }

    return String::toHexString (m.getRawData(), m.getRawDataSize());
}
Example #15
0
void MIDIReceiver::handleIncomingMidiMessage (MidiInput *source, const MidiMessage &message)
{
    DBG("midi in");
    // is this midi input source enabled
    if(_MidiDeviceManager->isMidiInputEnabled(source->getName()))
    {
        DBG(source->getName());

        if(message.isController() && _MidiDeviceManager->isCcEnabled(source->getName(), true)
                && appProperties->getUserSettings()->getIntValue("midiInputChannel") == message.getChannel())
        {

            DBG(message.getControllerNumber() );
            // reference counted Signal ( string command, string origin )
            Signal::SignalP ledStateSignal = new Signal("SEND_OSC", "RCV_MIDI");

            ledStateSignal->addStringArg("/nomestate/grid/led/set");
            // get the x position: LED bumber % 8
            ledStateSignal->addIntArg(message.getControllerNumber() % 8);
            // get the y position: LED number / 8
            ledStateSignal->addIntArg(message.getControllerNumber() / 8);
            // get the LED state: toggleState

            int ledState;
            if (message.getControllerValue() > 0) {
                ledState = 1;
            }

            ledStateSignal->addIntArg(ledState);

            _mCenter->handleSignal(*ledStateSignal);
        }
        else if (message.isNoteOn() && _MidiDeviceManager->isNoteEnabled(source->getName(), true)
                 && appProperties->getUserSettings()->getIntValue("midiInputChannel") == message.getChannel())
        {
            // lets set the color based off MIDI note Velocity
            int MIDIVelocity = message.getVelocity();
            int r = 0;
            int g = 0;
            int b = 0;

            if (MIDIVelocity > 0) {
                // red
                if (MIDIVelocity <= 22)
                {
                    r = 127;
                }
                // yellow
                else if (MIDIVelocity <= 43)
                {
                    r = 127;
                    g = 127;
                }
                // green
                else if (MIDIVelocity <= 64)
                {
                    g = 127;
                }
                // teal
                else if (MIDIVelocity <= 85)
                {
                    g = 127;
                    b = 127;
                }
                // blue
                else if (MIDIVelocity <= 106)
                {
                    b = 127;
                }
                // purple
                else
                {
                    b = 127;
                    r = 127;
                }
            }

            // reference counted Signal ( string command, string origin )
            Signal::SignalP ledColourSignal = new Signal("SEND_OSC", "RCV_MIDI");

            ledColourSignal->addStringArg("/nomestate/grid/led/color");
            // get the x position: LED bumber % 8
            ledColourSignal->addIntArg(message.getNoteNumber() % 8);
            // get the y position: LED number / 8
            ledColourSignal->addIntArg(message.getNoteNumber() / 8);
            // get the LED RED:
            ledColourSignal->addIntArg(r);
            // get the LED GREEN:
            ledColourSignal->addIntArg(g);
            // get the LED BLUE:
            ledColourSignal->addIntArg(b);

            _mCenter->handleSignal(*ledColourSignal);

            // reference counted Signal ( string command, string origin )
            Signal::SignalP ledStateSignal = new Signal("SEND_OSC", "RCV_MIDI");

            ledStateSignal->addStringArg("/nomestate/grid/led/set");
            // get the x position: LED bumber % 8
            ledStateSignal->addIntArg(message.getNoteNumber() % 8);
            // get the y position: LED number / 8
            ledStateSignal->addIntArg(message.getNoteNumber() / 8);
            // get the LED state: toggleState

            ledStateSignal->addIntArg(1);

            _mCenter->handleSignal(*ledStateSignal);


        }
        else if (message.isNoteOff() && _MidiDeviceManager->isNoteEnabled(source->getName(), true)
                 && appProperties->getUserSettings()->getIntValue("midiInputChannel") == message.getChannel())
        {
            // reference counted Signal ( string command, string origin )
            Signal::SignalP ledStateSignal = new Signal("SEND_OSC", "RCV_MIDI");

            ledStateSignal->addStringArg("/nomestate/grid/led/set");
            // get the x position: LED bumber % 8
            ledStateSignal->addIntArg(message.getNoteNumber() % 8);
            // get the y position: LED number / 8
            ledStateSignal->addIntArg(message.getNoteNumber() / 8);
            // get the LED state: toggleState

            ledStateSignal->addIntArg(0);

            _mCenter->handleSignal(*ledStateSignal);
        }

    }
}
Example #16
0
const String getName(const MidiMessage &m)
{
	if (m.isActiveSense())
	{
		return (" [Active Sense]");
	}

	if (m.isAftertouch())
	{
		return (" [Aftertouch]");
	}

	if (m.isAllNotesOff())
	{
		return (" [All notes off]");
	}

	if (m.isAllSoundOff())
	{
		return (" [All sound off]");
	}

	if (m.isChannelPressure())
	{
		return (" [Channel pressure]");
	}

	if (m.isController())
	{
		return (" [Controller]");
	}

	if (m.isFullFrame())
	{
		return (" [Full frame]");
	}

	if (m.isMetaEvent())
	{
		return (" [Meta event]");
	}

	if (m.isMidiClock())
	{
		return (" [MIDI Clock]");
	}

	if (m.isMidiContinue())
	{
		return (" [MIDI Continue]");
	}

	if (m.isMidiStart())
	{
		return (" [MIDI Start]");
	}

	if (m.isMidiStop())
	{
		return (" [MIDI Stop]");
	}

	if (m.isNoteOff())
	{
		return (" [Note off]");
	}

	if (m.isNoteOn())
	{
		return (" [Note on]");
	}

	if (m.isPitchWheel())
	{
		return (" [Pitch wheel]");
	}

	if (m.isProgramChange())
	{
		return (" [Program change]");
	}

	if (m.isQuarterFrame())
	{
		return (" Quarter frame]");
	}

	if (m.isSysEx())
	{
		return (" [System exclusive]");
	}

	return (" [Yet unknown]");
}
Example #17
0
void SynthAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    const int totalNumInputChannels  = getTotalNumInputChannels();
    const int totalNumOutputChannels = getTotalNumOutputChannels();

    // In case we have more outputs than inputs, this code clears any output
    // channels that didn't contain input data, (because these aren't
    // guaranteed to be empty - they may contain garbage).
    // This is here to avoid people getting screaming feedback
    // when they first compile a plugin, but obviously you don't need to keep
    // this code if your algorithm always overwrites all the output channels.

    MidiBuffer Midi;
    int time;
    MidiMessage m;
    
    for(MidiBuffer::Iterator i(midiMessages); i.getNextEvent(m, time);){
        
        //handle monophonic on/off of notes
        if(m.isNoteOn()){
            noteOn++;
        }
        if(m.isNoteOff()){
            noteOn--;
        }
        if(noteOn > 0){
            monoNoteOn = 1.0f;
            env.reset();
            //handle the pitch of the note
            noteVal = m.getNoteNumber();
            osc.setF(m.getMidiNoteInHertz(noteVal));
        }else{
            monoNoteOn = 0.0f;
        }
    }
    
    for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
        buffer.clear (i, 0, buffer.getNumSamples());

    for (int channel = 0; channel < totalNumOutputChannels; ++channel){
        
        //just do the synth stuff on one channel.
        if(channel == 0){


            for(int sample = 0; sample < buffer.getNumSamples(); ++sample){
  
				//do this stuff here.  it's terribly inefficient..
				freqValScaled = 20000.0f * pow(freqP->get(), 3.0f);
				envValScaled = 10000.0f *  pow(envP->get(), 3.0f);
				speedValScaled = pow((1.0f - speedP->get()), 2.0f);
				oscValScaled = (oscP->get() - 0.5f) * 70.0f;
				detValScaled = (detP->get() - 0.5f) * 24.0f;

                filter.setFc(freqSmoothing.process(freqValScaled + (envValScaled * pow(env.process(),3.0f))) / UPSAMPLING);
                env.setSpeed(speedValScaled);
                filter.setQ(qP->get());
				float frequency = noteVal + 24.0f + oscValScaled + modOsc.process(0) + (driftSmoothing.process(random.nextFloat() - 0.5f) * 20.0f);
                float frequency2 = exp((frequency + detValScaled + (driftSmoothing2.process(random.nextFloat() - 0.5f) * 10.0f)) / 17.31f) / UPSAMPLING;
				frequency = exp(frequency / 17.31f) / UPSAMPLING;
				osc.setF(frequency);
                osc2.setF(frequency2);
                float monoNoteOn2 = ampSmoothing.process(monoNoteOn);
                
                float data;
                
                for(int i = 0; i < UPSAMPLING; i++){
                    data = 20.0f * filter.process(0.1f * osc.process() + ampP->get() * 0.1f * osc2.process());
                }
                
                data *= monoNoteOn2;
                
                buffer.setSample(0, sample, data);
                buffer.setSample(1, sample, data);
            }
        }
    }
}
void JenSx1000AudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    int time;
    MidiMessage m;
    
    for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (m, time);)
    {
        if (m.isNoteOn())
        {
            int lastMidiNote = m.getNoteNumber();
            DBG("MIDI note triggered : " << lastMidiNote << "\n");
            heldNotes.insert(lastMidiNote);
        }
        else if (m.isNoteOff())
        {
            int releasedNote = m.getNoteNumber();
            DBG("MIDI note released : " << releasedNote << "\n");
            heldNotes.erase(releasedNote);
        }
        else if (m.isAftertouch())
        {
        }
        else if (m.isPitchWheel())
        {
        }
    }
    
    int highestHeldNote;
    
    if (heldNotes.empty()){
        if (currentNote > 0){
            DBG("Note released");
            ampEnvelope.release();
            vcf.release();
            currentNote = -1000;
            nextNote = -2000;
        }
    } else {
        highestHeldNote = *heldNotes.rbegin();
        if (nextNote != highestHeldNote){
            nextNote = highestHeldNote;
            noClick.start();
        }
    }
    
    
    std::vector<float*> ChannelData;
    
    for (int i = 0; i < getNumOutputChannels(); i++){
        ChannelData.push_back(buffer.getWritePointer(i));
    }
    
    for (int sample = 0; sample < buffer.getNumSamples(); ++sample){
        
        if (!heldNotes.empty() && currentNote != nextNote && noClick.fadingIn()){
            currentNote = nextNote;
            freqControl.setNote(currentNote);
            ampEnvelope.begin();
            vcf.begin();
        }
        
        float nextLFOSample = lfo.getNextSample();
        freqControl.setNextVibratoOscSample(nextLFOSample);
        vcf.setNextLFOSample(nextLFOSample);
        oscillator.setNextPWMSample(nextLFOSample);
        float nextNoClickSample = noClick.getNextSample();
        
        oscillator.updateFrequency(freqControl.getNextFrequency());
        
        float nextOscSample = oscillator.getNextSample();
        float nextNoiseSample = noise.getNextSample();
        float nextAmpSample = ampEnvelope.getNextSample();
        
        
        float nextSample = (vcf.processNextSample((nextOscSample * vcoLevel) + (nextNoiseSample * noiseLevel)) * nextAmpSample) * ampLevel *nextNoClickSample;
        
        for (float* channel : ChannelData){
            channel[sample] = nextSample;
        }
    }
}
Example #19
0
void RemoteGoatVstAudioProcessor::processBlock(AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
	//if (!midiMessages.isEmpty())
	//{
	//	String trace;
	//	trace << "MIDI:";
	//	for (int i = 0; i < midiMessages.data.size(); ++i)
	//	{
	//		trace << String::formatted(" %02X", midiMessages.data[i]);
	//	}
	//	writeTrace(trace);
	//}

	// For each sample name,
	// a sorted collection of "note on" event sample positions.
	std::map<String, std::set<std::pair<int, bool>>> noteOnSets;

	MidiBuffer::Iterator it(midiMessages);
	MidiMessage midiMessage;
	int samplePosition;
	while (it.getNextEvent(midiMessage, samplePosition))
	{
		// Check note number, map to sample name.
		int note = midiMessage.getNoteNumber();
		auto itt = _noteNumberSampleNameMap.find(note);
		if (itt != _noteNumberSampleNameMap.end())
		{
			String sampleName = itt->second;

			if (midiMessage.isNoteOn())
				// Save note on sample position for sample.
				noteOnSets[sampleName].insert(std::make_pair(samplePosition, true));
			else if (midiMessage.isNoteOff())
				noteOnSets[sampleName].insert(std::make_pair(samplePosition, false));
		}
	}

	midiMessages.clear();

	buffer.clear(0, 0, buffer.getNumSamples());
	buffer.clear(1, 0, buffer.getNumSamples());

	for (auto& samplePair : _samples)
	{
		Sample& sample = samplePair.second;
		auto noteOnSetsIterator = noteOnSets.find(sample.getName());
		if (noteOnSetsIterator != noteOnSets.end())
		{
			const std::set<std::pair<int, bool>>& noteOns = noteOnSetsIterator->second;
			int offset = noteOns.begin()->first;
			sample.read(buffer, 0, offset, false);
			for (auto noteOnIterator = noteOns.begin(); noteOnIterator != noteOns.end(); ++noteOnIterator)
			{
				int noteOn = noteOnIterator->first;
				bool onOrOff = noteOnIterator->second;
				writeTrace(String() << "Triggered " << sample.getName() + " (" << (int)onOrOff << ")");
				auto nextNoteOnIterator = noteOnIterator;
				++nextNoteOnIterator;
				if (nextNoteOnIterator != noteOns.end())
				{
					int nextNoteOn = nextNoteOnIterator->first;
					int diff = nextNoteOn - noteOn;
					if (onOrOff)
						sample.read(buffer, offset, diff, true);
					else
						sample.noteOff();
					offset += diff;
				}
				else
				{
					if (onOrOff)
						sample.read(buffer, offset, buffer.getNumSamples() - offset, true);
					else
						sample.noteOff();
				}
			}
		}
		else
		{
			sample.read(buffer, 0, buffer.getNumSamples(), false);
		}
	}
}
Example #20
0
void MiditoOscAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    static float cv[8], shiftcv[8];
    static bool _calibMode;
    
    MidiBuffer processedMidi;
    MidiMessage m;
    int time;
    
    char oscBuffer[IP_MTU_SIZE];
    osc::OutboundPacketStream p(oscBuffer, IP_MTU_SIZE);
    
    if (calibMode) // Calibration Mode A440Hz(MIDI number 69)
    {
        p << osc::BeginBundleImmediate
        << osc::BeginMessage( "/fader1" )
        << calibMap[69] << osc::EndMessage
        << osc::BeginMessage( "/fader2" )
        << calibMap[69] << osc::EndMessage
        << osc::BeginMessage( "/fader3" )
        << calibMap[69] << osc::EndMessage
        << osc::BeginMessage( "/fader4" )
        << calibMap[69] << osc::EndMessage
        << osc::BeginMessage( "/fader5" )
        << calibMap[69] << osc::EndMessage
        << osc::BeginMessage( "/fader6" )
        << calibMap[69] << osc::EndMessage
        << osc::BeginMessage( "/fader7" )
        << calibMap[69] << osc::EndMessage
        << osc::BeginMessage( "/fader8" )
        << calibMap[69] << osc::EndMessage
        << osc::BeginMessage( "/gate1" )
        << 1 << osc::EndMessage
        << osc::BeginMessage( "/gate2" )
        << 1 << osc::EndMessage
        << osc::EndBundle;
        
        sendOSCData(p);
        
        _calibMode = true;
        
        return;
        
    } else {
        
        if (_calibMode)
        {
            p << osc::BeginBundleImmediate
            << osc::BeginMessage( "/gate1" )
            << 0 << osc::EndMessage
            << osc::BeginMessage( "/gate2" )
            << 0 << osc::EndMessage
            << osc::EndBundle;
            
            sendOSCData(p);
            
            _calibMode = false;
            
        }
    }
    
    for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (m, time);)
    {
        p.Clear();
        usleep(30);
        
        if (m.isNoteOn())
        {
            if (monoMode) // mono Mode
            {
                uint32_t midiCh = m.getChannel();
                
                if (midiCh == 0 || midiCh > 7)
                {
                    midiCh = 1;
                }
                
                cv[midiCh - 1] = calibMap[m.getNoteNumber()];
                
                switch (midiCh)
                {
                    case 1:
                        p << osc::BeginMessage("/fader1")
                        << cv[0] << osc::EndMessage;
                        break;
                        
                    case 2:
                        p << osc::BeginMessage("/fader2")
                        << cv[1] << osc::EndMessage;
                        break;
                        
                    case 3:
                        p << osc::BeginMessage("/fader3")
                        << cv[2] << osc::EndMessage;
                        break;
                        
                    case 4:
                        p << osc::BeginMessage("/fader4")
                        << cv[3] << osc::EndMessage;
                        break;
                        
                    case 5:
                        p << osc::BeginMessage("/fader5")
                        << cv[4] << osc::EndMessage;
                        break;
                        
                    case 6:
                        p << osc::BeginMessage("/fader6")
                        << cv[5] << osc::EndMessage;
                        break;
                        
                    case 7:
                        p << osc::BeginMessage("/fader7")
                        << cv[6] << osc::EndMessage;
                        break;
                        
                    case 8:
                        p << osc::BeginMessage("/fader8")
                        << cv[7] << osc::EndMessage;
                        break;
                        
                    default:
                        break;
                }
                
                sendOSCData(p);
                
            } else if (shiftMode) { // shift Mode
                
                cv[0] = calibMap[m.getNoteNumber()];
                
                for (int i = 7; i > 0; i--)
                {
                    shiftcv[i] = shiftcv[i-1];
                }
                
                p << osc::BeginBundleImmediate
                << osc::BeginMessage( "/fader1" )
                << cv[0] << osc::EndMessage
                << osc::BeginMessage( "/fader2" )
                << shiftcv[1] << osc::EndMessage
                << osc::BeginMessage( "/fader3" )
                << shiftcv[2] << osc::EndMessage
                << osc::BeginMessage( "/fader4" )
                << shiftcv[3] << osc::EndMessage
                << osc::BeginMessage( "/fader5" )
                << shiftcv[4] << osc::EndMessage
                << osc::BeginMessage( "/fader6" )
                << shiftcv[5] << osc::EndMessage
                << osc::BeginMessage( "/fader7" )
                << shiftcv[6] << osc::EndMessage
                << osc::BeginMessage( "/fader8" )
                << shiftcv[7] << osc::EndMessage
                << osc::BeginMessage( "/gate1" )
                << 1 << osc::EndMessage
                << osc::BeginMessage( "/gate2" )
                << 1 << osc::EndMessage
                << osc::EndBundle;
                
                sendOSCData(p);
                
                shiftcv[0] = cv[0];
                
            } else { // poly Mode
                
                cv[ch] = calibMap[m.getNoteNumber()];
                
                if (currentMaxPoly == 1)
                {
                    cv[1] = cv[0];
                }
                
                p << osc::BeginBundleImmediate
                << osc::BeginMessage( "/fader1" )
                << cv[0] << osc::EndMessage
                << osc::BeginMessage( "/fader2" )
                << cv[1] << osc::EndMessage
                << osc::BeginMessage( "/fader3" )
                << cv[2] << osc::EndMessage
                << osc::BeginMessage( "/fader4" )
                << cv[3] << osc::EndMessage
                << osc::BeginMessage( "/fader5" )
                << cv[4] << osc::EndMessage
                << osc::BeginMessage( "/fader6" )
                << cv[5] << osc::EndMessage
                << osc::BeginMessage( "/fader7" )
                << m.getFloatVelocity() << osc::EndMessage
                << osc::BeginMessage( "/gate1" )
                << 1 << osc::EndMessage
                << osc::BeginMessage( "/gate2" )
                << 1 << osc::EndMessage
                << osc::EndBundle;
                
                sendOSCData(p);
                
                ch++;
                gateCount++;
                
                if (ch >= currentMaxPoly)
                {
                    ch = 0;
                }
                
            }
            
        } else if (m.isNoteOff()) {
            
            if (monoMode)
            {
                switch (m.getChannel())
                {
                    case 1:
                        p << osc::BeginMessage( "/gate1" )
                        << 0 << osc::EndMessage;
                        break;
                        
                    case 2:
                        p << osc::BeginMessage( "/gate2" )
                        << 0 << osc::EndMessage;
                        break;
                        
                    case 3:
                        p << osc::BeginMessage( "/gate3" )
                        << 0 << osc::EndMessage;
                        break;
                        
                    case 4:
                        p << osc::BeginMessage( "/gate4" )
                        << 0 << osc::EndMessage;
                        break;
                        
                    default:
                        break;
                }
                
                sendOSCData(p);
                
            } else if (shiftMode) {
                
                p << osc::BeginBundleImmediate
                << osc::BeginMessage( "/gate1" )
                << 0 << osc::EndMessage
                << osc::BeginMessage( "/gate2" )
                << 0 << osc::EndMessage
                << osc::EndBundle;
                
                sendOSCData(p);
                
            } else {
                
                gateCount --;
                
                if (gateCount <= 0)
                {
                    p << osc::BeginBundleImmediate
                    << osc::BeginMessage( "/gate1" )
                    << 0 << osc::EndMessage
                    << osc::BeginMessage( "/gate2" )
                    << 0 << osc::EndMessage
                    << osc::EndBundle;
                    
                    sendOSCData(p);
                    
                    gateCount = 0;
                }
                
                ch--;
                
                if (ch == -1)
                {
                    ch = 0;
                }
                
            }
            
        } else if (m.isControllerOfType(1)) { // Modulation Wheel
            
            float modulation = m.getControllerValue();
            
            if (!monoMode && !shiftMode)
            {
                p << osc::BeginMessage("/fader8")
                << (modulation / 127) << osc::EndMessage;
                
                sendOSCData(p);
            }
            
        }
        
        processedMidi.addEvent (m, time);
    }
    
    midiMessages.swapWith (processedMidi);
    
    buffer.clear();
    
    for (int channel = 0; channel < getNumInputChannels(); ++channel)
    {
        float* channelData = 0;
    }
}
Example #21
0
//==============================================================================
int main (int argc, char* argv[])
{
	if (argc != 3) {
		cout << "Usage: <prog> <midi input file> <wav output file>" << endl;
		return 0;
	}
	File inMidiFile = File(argv[1]);
	File outWavFile = File(argv[2]);

	//File inMidiFile = File("C:\\Users\\GeorgeKrueger\\Documents\\GitHub\\pymusic\\out.mid");
	//File outWavFile = File("C:\\Users\\GeorgeKrueger\\Documents\\GitHub\\pymusic\\out.wav");

	FileInputStream fileStream(inMidiFile);
	juce::MidiFile midiFile;
	midiFile.readFrom(fileStream);
	int numTracks = midiFile.getNumTracks();
	midiFile.convertTimestampTicksToSeconds();
	std::cout << "Opened midi file: " << inMidiFile.getFileName() << " Tracks: " << numTracks << std::endl;;

	playHead.posInfo.bpm = 120;
	playHead.posInfo.isPlaying = true;
	playHead.posInfo.timeInSamples = 0;
	playHead.posInfo.timeInSeconds = 0;
	playHead.posInfo.timeSigNumerator = 4;
	playHead.posInfo.timeSigDenominator = 4;

	for (int i = 0; i < numTracks; ++i)
	{
		const juce::MidiMessageSequence* msgSeq = midiFile.getTrack(i);

		double trackLengthSeconds = 0;
		String plugFile = "";
		int program = 0;
		for (int j = 0; j < msgSeq->getNumEvents(); ++j)
		{
			juce::MidiMessageSequence::MidiEventHolder* midiEventHolder = msgSeq->getEventPointer(j);
			juce::MidiMessage midiMsg = midiEventHolder->message;
			if (midiMsg.isMetaEvent() && midiMsg.getMetaEventType() == 0x04) {
				// Instrument meta event
				int instrLength = midiMsg.getMetaEventLength();
				const juce::uint8* instrChars = midiMsg.getMetaEventData();
				String instrName((char*)instrChars, instrLength);
				plugFile = instrName;
			}
			if (midiMsg.isMetaEvent() && midiMsg.isEndOfTrackMetaEvent()) {
				//int oetDataLength = midiMsg.getMetaEventLength();
				//const uint8* oetData = midiMsg.getMetaEventData();
				//std::cout << "Found end of track event data size: " << oetDataLength << " data: " << oetData << std::endl;
				trackLengthSeconds = midiMsg.getTimeStamp();
				std::cout << "Track length in seconds: " << trackLengthSeconds << std::endl;
			}
		}

		if (trackLengthSeconds == 0) {
			std::cerr << "Skipping track " << i << " since it has zero length" << std::endl;
			continue;
		}

		if (plugFile.isEmpty()) {
			plugFile = "C:\\VST\\helm.dll";
			std::cout << "No plug found for track. Defaulting to: " << plugFile << std::endl;
			//std::cerr << "Skipping track " << i << ". No instrument found." << std::endl;
			//continue;
		}
		else {
			std::cout << "Found plugin file '" << plugFile << "' from track " << i << std::endl;
		}

		OwnedArray<PluginDescription> results;
		VSTPluginFormat vstFormat;
		vstFormat.findAllTypesForFile(results, plugFile);
		if (results.size() > 0) {
			std::cout << "Found " << results.size() << " plugin(s) in file '" << plugFile << "'" << std::endl;

			int blockSize = 1024;
			double sampleRate = 44100;
			int totalSizeInSamples = ((static_cast<int>(44100 * trackLengthSeconds) / 1024) + 1) * 1024;
			cout << "Total samples to render " << totalSizeInSamples << endl;
			juce::AudioPluginInstance* plugInst = vstFormat.createInstanceFromDescription(*results[0], sampleRate, blockSize);
			if (!plugInst) {
				cout << "Failed to load plugin " << plugFile << endl;
				continue;
			}

			AudioProcessorGraph* graph = new AudioProcessorGraph();
			graph->setPlayConfigDetails(0, 2, sampleRate, blockSize);
			graph->setPlayHead(&playHead);
			graph->addNode(plugInst, 1000);

			int AUDIO_IN_ID = 101;
			int AUDIO_OUT_ID = 102;
			int MIDI_IN_ID = 103;
			juce::AudioPluginInstance* audioInNode = new AudioGraphIOProcessor(AudioGraphIOProcessor::audioInputNode);
			juce::AudioPluginInstance* audioOutNode = new AudioGraphIOProcessor(AudioGraphIOProcessor::audioOutputNode);
			juce::AudioPluginInstance* midiInNode = new AudioGraphIOProcessor(AudioGraphIOProcessor::midiInputNode);
			graph->addNode(audioInNode, AUDIO_IN_ID);
			graph->addNode(audioOutNode, AUDIO_OUT_ID);
			graph->addNode(midiInNode, MIDI_IN_ID);

			graph->addConnection(AUDIO_IN_ID, 0, 1000, 0);
			graph->addConnection(AUDIO_IN_ID, 1, 1000, 1);
			graph->addConnection(MIDI_IN_ID, AudioProcessorGraph::midiChannelIndex, 1000, AudioProcessorGraph::midiChannelIndex);
			graph->addConnection(1000, 0, AUDIO_OUT_ID, 0);
			graph->addConnection(1000, 1, AUDIO_OUT_ID, 1);

			plugInst->setCurrentProgram(program);

			int numInputChannels = plugInst->getTotalNumInputChannels();
			int numOutputChannels = plugInst->getTotalNumOutputChannels();
			cout << "----- Plugin Information -----" << endl;
			cout << "Input channels : " << numInputChannels << endl;
			cout << "Output channels : " << numOutputChannels << endl;
			cout << "Num Programs: " << plugInst->getNumPrograms() << endl;
			cout << "Current program: " << plugInst->getCurrentProgram() << endl;

			int numParams = plugInst->getNumParameters();
			cout << "Num Parameters: " << numParams << endl;
			for (int p = 0; p < numParams; ++p)
			{
				std::cout << "Param " << p << ": " << plugInst->getParameterName(p);
				if (!plugInst->getParameterLabel(p).isEmpty()) {
					cout << "(" << plugInst->getParameterLabel(p) << ")";
				}
				cout << " = " << plugInst->getParameter(p) << endl;
			}
			cout << "-----------------------------" << endl;

			int maxChannels = std::max(numInputChannels, numOutputChannels);
			AudioBuffer<float> entireAudioBuffer(maxChannels, totalSizeInSamples);
			entireAudioBuffer.clear();
			unsigned int midiSeqPos = 0;

			graph->releaseResources();
			graph->prepareToPlay(sampleRate, blockSize);

			cout << "Num midi events: " << msgSeq->getNumEvents() << endl;

			// Render the audio in blocks
			for (int t = 0; t < totalSizeInSamples; t += blockSize)
			{
				//cout << "processing block " << t << " to " << t + blockSize << endl;
				MidiBuffer midiBuffer;
				for (int j = midiSeqPos; j < msgSeq->getNumEvents(); ++j)
				{
					MidiMessageSequence::MidiEventHolder* midiEventHolder = msgSeq->getEventPointer(j);
					MidiMessage midiMsg = midiEventHolder->message;
					int samplePos = static_cast<int>(midiMsg.getTimeStamp() * sampleRate);
					if (samplePos >= t && samplePos < t + blockSize) {
						if (midiMsg.isNoteOnOrOff()) {
							if (midiMsg.isNoteOn()) {
								cout << "note on event (" << midiMsg.getNoteNumber() << ") at " << samplePos << "(" << midiMsg.getTimeStamp() << "s) bufferpos=" << (samplePos - t) << endl;
							}
							else if (midiMsg.isNoteOff()) {
								cout << "note off event (" << midiMsg.getNoteNumber() << ") at " << samplePos << "(" << midiMsg.getTimeStamp() << "s) bufferpos=" << (samplePos - t) << endl;
							}
							midiBuffer.addEvent(midiMsg, samplePos - t);
						}
						else if (midiMsg.isProgramChange()) {
							program = midiMsg.getProgramChangeNumber();
							plugInst->setCurrentProgram(program);
						}
						midiSeqPos++;
					}
					else {
						break;
					}
				}

				playHead.posInfo.timeInSamples = t;
				playHead.posInfo.timeInSeconds = t / sampleRate;

				AudioBuffer<float> blockAudioBuffer(entireAudioBuffer.getNumChannels(), blockSize);
				blockAudioBuffer.clear();
				graph->processBlock(blockAudioBuffer, midiBuffer);

				for (int ch = 0; ch < entireAudioBuffer.getNumChannels(); ++ch) {
					entireAudioBuffer.addFrom(ch, t, blockAudioBuffer, ch, 0, blockSize);
				}
			}

			if (outWavFile.exists()) {
				outWavFile.deleteFile();
			}
			FileOutputStream* fileOutputStream = outWavFile.createOutputStream();
			WavAudioFormat wavFormat;
			StringPairArray metadataValues;
			juce::AudioFormatWriter* wavFormatWriter = wavFormat.createWriterFor(
				fileOutputStream, sampleRate, 2, 16, metadataValues, 0);
			bool writeAudioDataRet = wavFormatWriter->writeFromAudioSampleBuffer(entireAudioBuffer, 0, entireAudioBuffer.getNumSamples());
			wavFormatWriter->flush();

			cout << "Done writing to output file " << outWavFile.getFileName() << " . Write return value: "
				<< (int)writeAudioDataRet << endl;

			delete wavFormatWriter;
		}
		else {
			cerr << "Could not find plugin from file " << plugFile << endl;
		}
	}

    return 0;
}