Add files via upload

pull/2/head
MrDham 7 years ago committed by GitHub
parent f5507ec2d9
commit b17940cba4
  1. 46
      Open_Theremin_V3/application.cpp

@ -600,6 +600,18 @@ void Application::midi_application ()
switch (_midistate) switch (_midistate)
{ {
case MIDI_SILENT: case MIDI_SILENT:
// Always refresh midi volume value (synth sound could be in Release phase of ADSR)
if (new_midi_volume != old_midi_volume)
{
midi_msg_send(midi_channel, 0xB0, 0x07, new_midi_volume);
old_midi_volume = new_midi_volume;
}
else
{
// do nothing
}
// If player's hand moves away from volume antenna // If player's hand moves away from volume antenna
if (new_midi_volume > midi_volume_trigger) if (new_midi_volume > midi_volume_trigger)
{ {
@ -607,10 +619,6 @@ void Application::midi_application ()
midi_msg_send(midi_channel, 0xE0, midi_bend_low, midi_bend_high); midi_msg_send(midi_channel, 0xE0, midi_bend_low, midi_bend_high);
old_midi_bend = new_midi_bend; old_midi_bend = new_midi_bend;
// Send volume to reach precise played volume
midi_msg_send(midi_channel, 0xB0, 0x07, new_midi_volume);
old_midi_volume = new_midi_volume;
// Play the note // Play the note
midi_msg_send(midi_channel, 0x90, new_midi_note, 0x45); midi_msg_send(midi_channel, 0x90, new_midi_note, 0x45);
old_midi_note = new_midi_note; old_midi_note = new_midi_note;
@ -627,25 +635,25 @@ void Application::midi_application ()
break; break;
case MIDI_PLAYING: case MIDI_PLAYING:
// If player's hand is far from volume antenna // Always refresh midi volume value
if (new_midi_volume > midi_volume_trigger) if (new_midi_volume != old_midi_volume)
{
// Refresh midi pitch bend value
if (new_midi_bend != old_midi_bend)
{ {
midi_msg_send(midi_channel, 0xE0, midi_bend_low, midi_bend_high); midi_msg_send(midi_channel, 0xB0, 0x07, new_midi_volume);
old_midi_bend = new_midi_bend; old_midi_volume = new_midi_volume;
} }
else else
{ {
// do nothing // do nothing
} }
// Refresh midi volume value // If player's hand is far from volume antenna
if (new_midi_volume != old_midi_volume) if (new_midi_volume > midi_volume_trigger)
{ {
midi_msg_send(midi_channel, 0xB0, 0x07, new_midi_volume); // Refresh midi pitch bend value
old_midi_volume = new_midi_volume; if (new_midi_bend != old_midi_bend)
{
midi_msg_send(midi_channel, 0xE0, midi_bend_low, midi_bend_high);
old_midi_bend = new_midi_bend;
} }
else else
{ {
@ -668,13 +676,13 @@ void Application::midi_application ()
} }
else // Means that player's hand moves to the volume antenna else // Means that player's hand moves to the volume antenna
{ {
// Send volume = 0
midi_msg_send(midi_channel, 0xB0, 0x07, 0);
old_midi_volume = 0;
// Send note off // Send note off
midi_msg_send(midi_channel, 0x90, old_midi_note, 0); midi_msg_send(midi_channel, 0x90, old_midi_note, 0);
// Don't refresh pitch bend:
// the following instruction "midi_key_follow = 0.5;" would make pitch bend verry messy
// and it simulates the impossibility of a vibrato on a mutted string (ok... theremin has no string)
// Set key follow to the minimum in order to use closest note played as the center note for pitch bend next time // Set key follow to the minimum in order to use closest note played as the center note for pitch bend next time
midi_key_follow = 0.5; midi_key_follow = 0.5;

Loading…
Cancel
Save