| 35 | #define TEST(name) static void name() |
| 36 | |
| 37 | TEST(testMidiOutput) { |
| 38 | static float audioBuffer[64]; |
| 39 | |
| 40 | Synthesizer *synth = new Synthesizer(); |
| 41 | synth->setSampleRate(44100); |
| 42 | |
| 43 | std::vector<amsynth_midi_event_t> midiIn; |
| 44 | std::vector<amsynth_midi_cc_t> midiOut; |
| 45 | |
| 46 | synth->process(32, midiIn, midiOut, &audioBuffer[0], &audioBuffer[32]); |
| 47 | |
| 48 | Param param = kAmsynthParameter_ReverbWet; |
| 49 | |
| 50 | unsigned char cc = 2; |
| 51 | synth->getMidiController()->setControllerForParameter(param, cc); |
| 52 | |
| 53 | for (unsigned char value = 0; value <= 127; value++) { |
| 54 | unsigned char midi[4] = { MIDI_STATUS_CONTROLLER, cc, value }; |
| 55 | amsynth_midi_event_t event; |
| 56 | event.length = 3; |
| 57 | event.offset_frames = 0; |
| 58 | event.buffer = midi; |
| 59 | midiIn.clear(); |
| 60 | midiIn.push_back(event); |
| 61 | |
| 62 | midiOut.clear(); |
| 63 | synth->process(32, midiIn, midiOut, &audioBuffer[0], &audioBuffer[32]); |
| 64 | |
| 65 | int outputValue = (int)roundf(synth->getNormalizedParameterValue(param) * 127.0f); |
| 66 | assert(outputValue == value || 0 == "parameter value should be changed when a cc is processed"); |
| 67 | |
| 68 | assert(midiOut.empty() || 0 == "no midi output should be generated when a cc is processed"); |
| 69 | } |
| 70 | |
| 71 | midiIn.clear(); |
| 72 | midiOut.clear(); |
| 73 | synth->setNormalizedParameterValue(param, 0); |
| 74 | synth->process(32, midiIn, midiOut, &audioBuffer[0], &audioBuffer[32]); |
| 75 | assert(midiOut.size() == 1 || 0 == "midi output should be generated when a parameter is changed"); |
| 76 | assert(midiOut[0].value == 0 || 0 == "midi output value is incorrect"); |
| 77 | |
| 78 | delete synth; |
| 79 | } |
| 80 | |
| 81 | TEST(testMidiOutput_OnOff) { |
| 82 | Synthesizer *synth = new Synthesizer(); |
nothing calls this directly
no test coverage detected