4 |
* * |
* * |
5 |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005-2008 Christian Schoenebeck * |
* Copyright (C) 2005-2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009-2010 Christian Schoenebeck and Grigor Iliev * |
* Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev * |
8 |
|
* Copyright (C) 2013-2014 Christian Schoenebeck and Andreas Persson * |
9 |
* * |
* * |
10 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
11 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
348 |
*/ |
*/ |
349 |
uint8_t AbstractEngine::GSCheckSum(const RingBuffer<uint8_t,false>::NonVolatileReader AddrReader, uint DataSize) { |
uint8_t AbstractEngine::GSCheckSum(const RingBuffer<uint8_t,false>::NonVolatileReader AddrReader, uint DataSize) { |
350 |
RingBuffer<uint8_t,false>::NonVolatileReader reader = AddrReader; |
RingBuffer<uint8_t,false>::NonVolatileReader reader = AddrReader; |
351 |
uint bytes = 3 /*addr*/ + DataSize; |
uint bytes = 3 /*addr*/ + DataSize; |
|
uint8_t addr_and_data[bytes]; |
|
|
reader.read(&addr_and_data[0], bytes); |
|
352 |
uint8_t sum = 0; |
uint8_t sum = 0; |
353 |
for (uint i = 0; i < bytes; i++) sum += addr_and_data[i]; |
uint8_t c; |
354 |
|
for (uint i = 0; i < bytes; ++i) { |
355 |
|
if (!reader.pop(&c)) break; |
356 |
|
sum += c; |
357 |
|
} |
358 |
return 128 - sum % 128; |
return 128 - sum % 128; |
359 |
} |
} |
360 |
|
|
516 |
for (int i = 0; i < engineChannels.size(); ++i) { |
for (int i = 0; i < engineChannels.size(); ++i) { |
517 |
AbstractEngineChannel* pEngineChannel |
AbstractEngineChannel* pEngineChannel |
518 |
= static_cast<AbstractEngineChannel*>(engineChannels[i]); |
= static_cast<AbstractEngineChannel*>(engineChannels[i]); |
519 |
if (pEngineChannel->GetMidiInputPort() == itSysexEvent->pMidiInputPort) { |
Sync< ArrayList<MidiInputPort*> > midiInputs = pEngineChannel->midiInputs.front(); |
520 |
KillAllVoices(pEngineChannel, itSysexEvent); |
for (int k = 0; k < midiInputs->size(); ++k) { |
521 |
pEngineChannel->ResetControllers(); |
if ((*midiInputs)[k] == itSysexEvent->pMidiInputPort) { |
522 |
|
KillAllVoices(pEngineChannel, itSysexEvent); |
523 |
|
pEngineChannel->ResetControllers(); |
524 |
|
break; |
525 |
|
} |
526 |
} |
} |
527 |
} |
} |
528 |
} |
} |
555 |
for (int i = 0; i < engineChannels.size(); ++i) { |
for (int i = 0; i < engineChannels.size(); ++i) { |
556 |
AbstractEngineChannel* pEngineChannel |
AbstractEngineChannel* pEngineChannel |
557 |
= static_cast<AbstractEngineChannel*>(engineChannels[i]); |
= static_cast<AbstractEngineChannel*>(engineChannels[i]); |
558 |
if ( |
if (pEngineChannel->midiChannel == part || |
559 |
(pEngineChannel->midiChannel == part || |
pEngineChannel->midiChannel == midi_chan_all) |
560 |
pEngineChannel->midiChannel == midi_chan_all) && |
{ |
561 |
pEngineChannel->GetMidiInputPort() == itSysexEvent->pMidiInputPort |
Sync< ArrayList<MidiInputPort*> > midiInputs = pEngineChannel->midiInputs.front(); |
562 |
) { |
for (int k = 0; k < midiInputs->size(); ++k) { |
563 |
try { |
if ((*midiInputs)[k] == itSysexEvent->pMidiInputPort) { |
564 |
pEngineChannel->SetMidiInstrumentMap(map); |
try { |
565 |
} catch (Exception e) { |
pEngineChannel->SetMidiInstrumentMap(map); |
566 |
dmsg(2,("\t\t\tCould not apply MIDI instrument map %d to part %d: %s\n", map, part, e.Message().c_str())); |
} catch (Exception e) { |
567 |
goto free_sysex_data; |
dmsg(2,("\t\t\tCould not apply MIDI instrument map %d to part %d: %s\n", map, part, e.Message().c_str())); |
568 |
} catch (...) { |
goto free_sysex_data; |
569 |
dmsg(2,("\t\t\tCould not apply MIDI instrument map %d to part %d (unknown exception)\n", map, part)); |
} catch (...) { |
570 |
goto free_sysex_data; |
dmsg(2,("\t\t\tCould not apply MIDI instrument map %d to part %d (unknown exception)\n", map, part)); |
571 |
|
goto free_sysex_data; |
572 |
|
} |
573 |
|
break; |
574 |
|
} |
575 |
} |
} |
576 |
} |
} |
577 |
} |
} |