| 304 | } |
| 305 | |
| 306 | void CMIDI::WriteNote(unsigned char Channel, ft0cc::doc::pitch Note, unsigned char Octave, unsigned char Velocity) // // // |
| 307 | { |
| 308 | static unsigned int LastNote[CHANID_COUNT] = { }; // // // Quick hack |
| 309 | // static unsigned int LastVolume[CHANID_COUNT]; |
| 310 | |
| 311 | if (/*!m_bOpened ||*/ m_iOutDevice == 0 || m_hMIDIOut == NULL) |
| 312 | return; |
| 313 | |
| 314 | if (Note == note_t::none) |
| 315 | return; |
| 316 | |
| 317 | ++Octave; |
| 318 | |
| 319 | if ((Channel == 4 || Channel == 3) && Octave < 3) |
| 320 | Octave += 3; |
| 321 | |
| 322 | if (Velocity == 0x10) |
| 323 | --Velocity; |
| 324 | /* |
| 325 | Velocity = LastVolume[Channel]; |
| 326 | else |
| 327 | LastVolume[Channel] = Velocity;*/ |
| 328 | |
| 329 | unsigned int MsgChannel = Channel; |
| 330 | unsigned int MsgType; |
| 331 | |
| 332 | unsigned int Data1 = ft0cc::doc::midi_note(Octave, Note); // note |
| 333 | unsigned int Data2 = Velocity * 8; // velocity |
| 334 | |
| 335 | if (Note == note_t::halt || Note == note_t::release) { |
| 336 | MsgType = MIDI_MSG_NOTE_OFF; |
| 337 | Data2 = 0; |
| 338 | Data1 = LastNote[Channel]; |
| 339 | LastNote[Channel] = 0; |
| 340 | } |
| 341 | else { |
| 342 | if (LastNote[Channel] != 0 && Data1 != LastNote[Channel]) |
| 343 | WriteNote(Channel, note_t::halt, 0, 0); |
| 344 | |
| 345 | MsgType = MIDI_MSG_NOTE_ON; |
| 346 | LastNote[Channel] = Data1; |
| 347 | } |
| 348 | |
| 349 | unsigned int Status = (MsgType << 4) | MsgChannel; |
| 350 | unsigned int dwParam1 = Status | (Data1 << 8) | (Data2 << 16); |
| 351 | |
| 352 | midiOutShortMsg(m_hMIDIOut, dwParam1); |
| 353 | } |
| 354 | |
| 355 | void CMIDI::ResetOutput() |
| 356 | { |
no test coverage detected