示例#1
0
static void RT_process(SoundPlugin *plugin, int64_t time, int num_frames, float **inputs, float **outputs){
  
  Data *data = (Data*)plugin->data;

#if 0
  for(int ch=0; ch<data->num_output_channels ; ch++)
    memset(outputs[ch], 0, sizeof(float)*num_frames);
  return;
#endif

  // 1. Process audio

  AudioPluginInstance *instance = data->audio_instance;
  AudioSampleBuffer &buffer = data->buffer;

  for(int ch=0; ch<data->num_input_channels ; ch++)
    memcpy(buffer.getWritePointer(ch), inputs[ch], sizeof(float)*num_frames);

  int pos = CRASHREPORTER_set_plugin_name(plugin->type->name);{
    instance->processBlock(buffer, data->midi_buffer);
  }CRASHREPORTER_unset_plugin_name(pos);

  for(int ch=0; ch<data->num_output_channels ; ch++)
    memcpy(outputs[ch], buffer.getReadPointer(ch), sizeof(float)*num_frames);


  // 2. Send out midi (untested, need plugin to test with)

  volatile struct Patch *patch = plugin->patch;
  if (patch!=NULL) {
      
    MidiBuffer::Iterator iterator(data->midi_buffer);
      
    MidiMessage message;
    int samplePosition;
    
    while(iterator.getNextEvent(message, samplePosition)){
#ifndef RELEASE
      if (samplePosition >= num_frames || samplePosition < 0)
        RT_message("The instrument named \"%s\" of type %s/%s\n"
                   "returned illegal sample position: %d",
                   patch==NULL?"<no name>":patch->name,
                   plugin->type->type_name, plugin->type->name,
                   samplePosition
                   );
#endif
      // Make sure samplePosition has a legal value
      if (samplePosition >= num_frames)
        samplePosition = num_frames-1;
      if (samplePosition < 0)
        samplePosition = 0;
      
      int64_t delta_time = PLAYER_get_block_delta_time(pc->start_time+samplePosition);
      int64_t radium_time = pc->start_time + delta_time;
      
      RT_MIDI_send_msg_to_patch_receivers((struct Patch*)patch, message, radium_time);
    }
  }

}
示例#2
0
static void send_msg(struct SoundPlugin *plugin, int64_t block_delta_time, unsigned int byte1, unsigned int byte2, int byte3){
  Data *data = (Data*)plugin->data;
  volatile struct Patch *patch = plugin->patch;

  if (patch==NULL) // happens during initialization
    return;
  
  byte1 |= data->values[CHANNEL];

  uint32_t msg;

  if (byte3==-1)
    msg = MIDI_msg_pack2(byte1, byte2);
  else
    msg = MIDI_msg_pack3(byte1, byte2, byte3);

  struct SeqTrack *seqtrack = g_RT_curr_scheduling_seqtrack;
  int64_t delta_time = PLAYER_get_block_delta_time(seqtrack, seqtrack->start_time + block_delta_time);
  int64_t radium_time = seqtrack->start_time + delta_time;

  RT_PATCH_send_raw_midi_message_to_receivers(seqtrack, (struct Patch*)patch, msg, radium_time);
}