#include <DevMidi.h>
Öffentliche Methoden | |
OutMidiPort () | |
OutMidiPort (wxString name, int devId, int bendingRange=2) | |
~OutMidiPort () | |
virtual void | Save (tree_storage &config) |
Save current device settings in a tree storage. | |
virtual void | Save (tree_storage &config, const Route *route) |
Save route settings (filter settings) for a given route. | |
virtual void | Load (tree_storage &config) |
Load current device settings from a tree storage. | |
virtual void | Load (tree_storage &config, Route *route) |
Loade route settings (filter settings) for a given route. | |
virtual bool | Open () |
virtual void | Close () |
virtual void | NoteOn (int Box, int taste, int velo, Route *r, int channel, ChannelData *cd) |
virtual void | NoteOff (int Box, int taste, int velo, Route *r, int channel) |
virtual void | NotesCorrect (int box) |
virtual void | Sustain (char on, int channel) |
virtual int | GetChannel (int taste) |
virtual void | Gis (GisToken *token, char turn) |
virtual void | AddTime (frac time) |
virtual void | MidiOut (DWORD data, char n) |
virtual void | MidiOut (BYTE *p, char n) |
virtual void | Quite (Route *r) |
virtual void | Panic () |
virtual bool | NeedsRealTime () |
virtual void | SetDevId (int id) |
void | SetBendingRange (int r) |
int | GetBendingRange () |
virtual DevType | GetType () const |
virtual mutString | GetTypeName () const |
virtual void | ReadData (wxConfigBase *config) |
virtual void | WriteData (wxConfigBase *config) |
virtual int | GetMaxChannel () const |
virtual int | GetMinChannel () const |
Private Attribute | |
int | bending_range |
HMIDIOUT | hMidiOut |
ChannelData | Cd [16] |
char | KeyDir [16] |
TonAufKanal | ton_auf_kanal [16] |
int | nKeyOn |
OutMidiPort::OutMidiPort | ( | ) | [inline] |
OutMidiPort::OutMidiPort | ( | wxString | name, |
int | devId, | ||
int | bendingRange = 2 |
||
) | [inline] |
virtual void OutMidiPort::AddTime | ( | frac | time | ) | [inline, virtual] |
void OutMidiPort::Close | ( | ) | [virtual] |
Implementiert OutDevice.
Definiert in Zeile 253 der Datei DevMidi.cpp.
Benutzt DEBUGLOG, hMidiOut, KeyDir, MIDI_OUT3 und ton_auf_kanal.
{ DEBUGLOG (other, _T("")); // alle liegenden Tˆne ausschalten for (int i = 0; i < 16; i++) if ( KeyDir[i] >= 16 ) // benutzt MIDI_OUT3(0x80+i, ton_auf_kanal[i].key, 64); /* for (int i = 0; i < 16; i++) MidiOut3(176+i, 122, 1); // local on */ // Device schlieflen #ifdef RTMIDI hMidiOut->closePort(); delete hMidiOut; #else midiOutClose(hMidiOut); #endif }
int OutMidiPort::GetBendingRange | ( | ) | [inline] |
Definiert in Zeile 136 der Datei DevMidi.h.
Benutzt bending_range.
Wird benutzt von compat30::SaveRoutes().
{ return bending_range; }
int OutMidiPort::GetChannel | ( | int | taste | ) | [virtual] |
Implementiert OutDevice.
Definiert in Zeile 502 der Datei DevMidi.cpp.
Benutzt DEBUGLOG und ton_auf_kanal.
{ DEBUGLOG (other, _T("")); for (int i = 0; i < 16; i++) if ( ton_auf_kanal[i].id && (ton_auf_kanal[i].taste == taste) ) return i; return -1; }
virtual int OutMidiPort::GetMaxChannel | ( | ) | const [inline, virtual] |
Definiert in Zeile 173 der Datei DevMidi.h.
Wird benutzt von MutOutputMidiDeviceShape::GetOutputFilterPanel() und Load().
{ return 15; }
virtual int OutMidiPort::GetMinChannel | ( | ) | const [inline, virtual] |
Definiert in Zeile 174 der Datei DevMidi.h.
Wird benutzt von MutOutputMidiDeviceShape::GetOutputFilterPanel() und Load().
{ return 0; }
virtual DevType OutMidiPort::GetType | ( | ) | const [inline, virtual] |
Erneute Implementation von OutDevice.
Definiert in Zeile 141 der Datei DevMidi.h.
Benutzt DTMidiPort.
{ return DTMidiPort; }
virtual mutString OutMidiPort::GetTypeName | ( | ) | const [inline, virtual] |
void OutMidiPort::Load | ( | tree_storage & | config, |
Route * | route | ||
) | [virtual] |
Loade route settings (filter settings) for a given route.
Some route settings (e.g. filter settings) are device type specific. This function loads them from a tree storage. config (tree_storage *) Storage class, where the data will be restored from. route (Route *) Route whos data shall be loaded.
Implementiert Device.
Definiert in Zeile 184 der Datei DevMidi.cpp.
Benutzt _(), GetMaxChannel(), GetMinChannel(), Device::GetName(), Route::OFrom, Route::ONoDrum, Route::OTo und tree_storage::Read().
{ wxASSERT(route); route->ONoDrum = config.Read(_T("Avoid Drum Channel"), true); int oldfrom, oldto; oldfrom = route->OFrom = config.Read(_T("Channel Range From"), GetMinChannel()); oldto = route->OTo = config.Read(_T("Channel Range To"), GetMaxChannel()); bool correct = true; if (route->OFrom < GetMinChannel()) { correct = false; route->OFrom = GetMinChannel(); } if (route->OTo > GetMaxChannel()) { correct = false; route->OTo = GetMaxChannel(); } if (!correct) wxMessageBox(wxString::Format(_("The Channel range %d--%d of the MIDI output device %s must be inside %d--%d. The current route had to be corrected."), oldfrom,oldto,GetName().c_str(),GetMinChannel(),GetMaxChannel()), _("Warning loading route"),wxICON_EXCLAMATION); }
void OutMidiPort::Load | ( | tree_storage & | config | ) | [virtual] |
Load current device settings from a tree storage.
config (tree_storage) storage class, where the data will be loaded from.
Implementiert Device.
Definiert in Zeile 170 der Datei DevMidi.cpp.
Benutzt _(), bending_range, Device::DevId, RtMidiOut::getPortCount(), RtMidiOut::getPortName(), muT, Device::Name und tree_storage::Read().
{ DevId = config.Read(_T("Device Id"),0); Name = config.Read(_T("Device Name"), rtmidiout->getPortCount()? muT(rtmidiout->getPortName(0).c_str()):wxString(_("Unknown"))); bending_range = config.Read(_T("Bending Range"),2); }
void OutMidiPort::MidiOut | ( | DWORD | data, |
char | n | ||
) | [virtual] |
virtual void OutMidiPort::MidiOut | ( | BYTE * | p, |
char | n | ||
) | [inline, virtual] |
virtual bool OutMidiPort::NeedsRealTime | ( | ) | [inline, virtual] |
void OutMidiPort::NoteOff | ( | int | Box, |
int | taste, | ||
int | velo, | ||
Route * | r, | ||
int | channel | ||
) | [virtual] |
Implementiert OutDevice.
Definiert in Zeile 393 der Datei DevMidi.cpp.
Benutzt DEBUGLOG, DRUMCHANNEL, KeyDir, MAKE_ID, MAX_BOX, MIDI_OUT3, nKeyOn, Route::OFrom, Route::ONoDrum, TAK::taste und ton_auf_kanal.
Wird benutzt von Quite().
{ DEBUGLOG (midiio, _T("box %d, key %d, velo %d, channel %d"), box, taste, velo, channel); if ( box == -2 ) box = MAX_BOX+1; DWORD id = MAKE_ID(r, box, taste, channel); if ( !velo ) //3 ?? notwendig? velo = 64; for (int i = r->OFrom; i <= r->OTo; i++) if ( i != DRUMCHANNEL || !r->ONoDrum ) if ( KeyDir[i] >= 16 && ton_auf_kanal[i].id == id ) { ton_auf_kanal[i].taste=0; // ??? ton_auf_kanal[i].id=0; MIDI_OUT3(0x80+i, ton_auf_kanal[i].key, velo); // KeyDir umsortieren int oldKeyDir = KeyDir[i]; for (int k = 0; k < 16; k++) if ( KeyDir[k] > oldKeyDir || KeyDir[k] < 16) KeyDir[k]--; nKeyOn--; KeyDir[i] = 15; } }
void OutMidiPort::NoteOn | ( | int | Box, |
int | taste, | ||
int | velo, | ||
Route * | r, | ||
int | channel, | ||
ChannelData * | cd | ||
) | [virtual] |
Implementiert OutDevice.
Definiert in Zeile 277 der Datei DevMidi.cpp.
Benutzt ChannelData::BankSelectLSB, ChannelData::BankSelectMSB, Cd, char, DEBUGLOG, DRUMCHANNEL, GET_FREQ, TAK::id, TAK::key, KeyDir, MAKE_ID, MIDI_OUT3, MIDI_PITCH, MIDI_SOUND, mut_box, nKeyOn, Route::OFrom, Route::ONoDrum, Route::OTo, ChannelData::Pitch, ChannelData::Sound, ChannelData::Sustain, Sustain(), TAK::taste und ton_auf_kanal.
{ DEBUGLOG (other, _T("box %d, key %d, velo %d, channel %d"), box, taste, velo, channel); int free = 16, freeSus = r->OTo, freeV = 64, freeSusV = 64, s; DWORD p; long freq; if ( box == -2 ) { freq = ((long)taste) << 24; box = 255; } else freq = GET_FREQ (taste, mut_box[box].tonesystem); // testen, ob nicht belegte Taste if ( !freq ) return; for ( int j = r->OFrom; j <= r->OTo; j++ ) if ( j != DRUMCHANNEL || !r->ONoDrum ) { if ( Cd[j].Sustain ) { if ( KeyDir[j] < freeSusV ) { freeSus = j; freeSusV = KeyDir[j]; } } else { if ( KeyDir[j] < freeV ) { free = j; freeV = KeyDir[j]; } } } if ( freeV >= 16 ) { free = freeSus; freeV = freeSusV; } if ( freeV >= 16 ) // keinen freien gefunden { // "mittelste Taste weglassen" int AM = 0; // arithmetisches Mittel der Tasten int j; for (j = r->OFrom; j <= r->OTo; j++) if ( j != DRUMCHANNEL || !r->ONoDrum ) AM += ton_auf_kanal[j].taste; AM /= r->OTo + 1 - r->OFrom; for ( j = r->OFrom; j <= r->OTo; j++ ) if ( j != DRUMCHANNEL || !r->ONoDrum ) if ( abs(AM - ton_auf_kanal[j].taste) < abs(AM - ton_auf_kanal[free].taste) ) free = j; // Ton auf Kanal free ausschalten MIDI_OUT3(0x80+free, ton_auf_kanal[free].key, 64); // evtl. Sustain ausschalten if ( Cd[free].Sustain ) MIDI_OUT3(0xB0+free, 64, 0); // KeyDir umsortieren BYTE oldKeyDir = KeyDir[free]; for (int k = 0; k < 16; k++) if ( KeyDir[k] > oldKeyDir ) KeyDir[k]--; KeyDir[free] = (char)(15+nKeyOn); } else { nKeyOn++; KeyDir[free] = (char)(15 + nKeyOn); } // freier Kanal = free // evtl. Sustain ausschalten if ( Cd[free].Sustain ) { MIDI_OUT3(0xB0+free, 64, 0); Cd[free].Sustain = 0; } // Sound testen if ( (s = cd->Sound) != Cd[free].Sound ) { MIDI_SOUND(free, s); Cd[free].Sound = s; } // Bank testen if ( (s = cd->BankSelectMSB) != Cd[free].BankSelectMSB && s != -1 ) { MIDI_OUT3(0xB0+free, 0, (BYTE) s); Cd[free].BankSelectMSB = s; } if ( (s = cd->BankSelectLSB) != Cd[free].BankSelectLSB && s != -1 ) { MIDI_OUT3(0xB0+free, 32, (BYTE) s); Cd[free].BankSelectLSB = s; } // Pitch testen if ( (long)(p = (freq & 0xFFFFFF)) != Cd[free].Pitch ) { MIDI_PITCH(free, freq); Cd[free].Pitch = p; } ton_auf_kanal[free].key = (freq >> 24) & 0x7f; ton_auf_kanal[free].taste = taste; ton_auf_kanal[free].id = MAKE_ID(r, box, taste, channel); MIDI_OUT3(0x90+free, ton_auf_kanal[free].key, velo); if ( cd->Sustain ) { MIDI_OUT3(0xB0+free, 64, cd->Sustain); Cd[free].Sustain = cd->Sustain; } };
void OutMidiPort::NotesCorrect | ( | int | box | ) | [virtual] |
Implementiert OutDevice.
Definiert in Zeile 429 der Datei DevMidi.cpp.
Benutzt bending_range, Cd, DEBUGLOG, GET_FREQ, TAK::id, TAK::key, KeyDir, LongAbs(), MIDI_OUT3, mut_box, ChannelData::Pitch, ChannelData::Sustain, Sustain() und ton_auf_kanal.
{ DEBUGLOG (midiio, _T("")); for (int i = 0; i < 16; i++) if ( (KeyDir[i] >= 16 && ton_auf_kanal[i].id) || Cd[i].Sustain ) { int Box = (ton_auf_kanal[i].id >> 8) & 0xFF; if ( Box != box ) break; DEBUGLOG(midiio,_T("old(hex/dec): channel = %01x/%d, Taste = %02x/%d, key = %02x/%d, pitch = %06x/%d"), i,i,ton_auf_kanal[i].taste,ton_auf_kanal[i].taste, ton_auf_kanal[i].key,ton_auf_kanal[i].key,Cd[i].Pitch,Cd[i].Pitch); long freq = GET_FREQ(ton_auf_kanal[i].taste, mut_box[Box].tonesystem); // hier kann ein evtl. grˆflerer bending_range genutzt werden, um // Ton aus und einschalten zu vermeiden if ( ton_auf_kanal[i].key == ((freq >> 24) & 0x7f) && Cd[i].Pitch == ((long)freq & 0xFFFFFF) ) continue; long Delta = freq - ((long)ton_auf_kanal[i].key << 24); bool SwitchTone = (LongAbs(Delta) >= ((long)bending_range << 24)); // evtl. Ton ausschalten if ( SwitchTone ) { if ( Cd[i].Sustain ) { MIDI_OUT3(0xB0+i, 64, 0); Cd[i].Sustain = 0; if ( KeyDir[i] < 16 ) continue; } MIDI_OUT3(0x80+i, ton_auf_kanal[i].key, 0x7F); ton_auf_kanal[i].key = (freq >> 24) & 0x7F; Delta = freq - ((long)ton_auf_kanal[i].key << 24); } else if ( Delta == Cd[i].Pitch ) continue; // Spezialbending (grofler Range) Cd[i].Pitch = Delta; Delta /= bending_range; Delta = Delta >> 11; Delta += 0x40 << 7; // we have to add here as Delta can be negative DEBUGLOG(midiio,_T("new freq = %08x/%d, Pitch= %06x/%d, Delta = %06x/%d, i=%d"), freq, freq, Cd[i].Pitch, Cd[i].Pitch, Delta, Delta, i); // MIDI_OUT3(0xE0+i, ((BYTE*)&Delta)[1] >> 1, (((BYTE*)&Delta)[2])); MIDI_OUT3(0xE0+i, Delta & 0x7f, (Delta >> 7) & 0x7f ); // evtl. Ton einschalten if ( SwitchTone ) MIDI_OUT3(0x90+i, ton_auf_kanal[i].key, 64); //3 velo speichern ?? } }
bool OutMidiPort::Open | ( | ) | [virtual] |
Implementiert OutDevice.
Definiert in Zeile 207 der Datei DevMidi.cpp.
Benutzt _(), Cd, DEBUGLOG, Device::DevId, Device::GetName(), hMidiOut, TAK::id, KeyDir, LAUFZEIT_ERROR0, LAUFZEIT_ERROR2, MIDI_OUT3, nKeyOn, ChannelData::Reset(), TAK::taste und ton_auf_kanal.
{ DEBUGLOG (other, _T("")); int i; for (i = 0; i < 16; i++) { Cd[i].Reset(); ton_auf_kanal[i].taste = 0; ton_auf_kanal[i].id = 0; } nKeyOn = 0; for (i = 0; i < 16; i++) KeyDir[i] = (char)i; // alle nicht benutzt #ifdef RTMIDI // RtMidiIn constructor try { hMidiOut = new RtMidiOut(); } catch (RtError &error) { LAUFZEIT_ERROR0(_("Can not open ouput Midi devices.")); return false; } try { hMidiOut->openPort(DevId); } catch (RtError &error) { LAUFZEIT_ERROR2(_("Can not open output Midi device nr. %d (%s)"), DevId, (GetName().c_str())); return false; } #else midiOutOpen(&hMidiOut, DevId, NULL, NULL, NULL); #endif for (i = 0; i < 16; i++) { MIDI_OUT3(0xE0+i, 0x00, 0x40); // pitch auf 0 MIDI_OUT3(0xB0+i, 122, 0); // local off MIDI_OUT3(0xB0+i, 125, 0); // omni on MIDI_OUT3(0xB0+i, 127, 0); // poly on } return true; }
void OutMidiPort::Panic | ( | ) | [virtual] |
Erneute Implementation von OutDevice.
Definiert in Zeile 547 der Datei DevMidi.cpp.
Benutzt Cd, DEBUGLOG, TAK::id, KeyDir, MIDI_OUT2, MIDI_OUT3, nKeyOn, ChannelData::Sound, ChannelData::Sustain, TAK::taste und ton_auf_kanal.
{ DEBUGLOG (other, _T("")); for (int i = 0; i < 16; i++) { MIDI_OUT3(176+i, 123, 0); // All notes off */ MIDI_OUT3(0xB0+i, 7, 127); // main volume // sound piano MIDI_OUT2(0xC0+i, 0); // Merker aufr‰umen ton_auf_kanal[i].taste=0; ton_auf_kanal[i].id=0; Cd[i].Sound = 0; Cd[i].Sustain = 0; KeyDir[i] = i; // alle nicht benutzt } nKeyOn = 0; }
void OutMidiPort::Quite | ( | Route * | r | ) | [virtual] |
Implementiert OutDevice.
Definiert in Zeile 538 der Datei DevMidi.cpp.
Benutzt Route::Box, DEBUGLOG, Route::GetId(), TAK::id, NoteOff() und ton_auf_kanal.
{ DEBUGLOG (other, _T("")); for (int i = 0; i < 16; i++) if ( (char)((ton_auf_kanal[i].id >> 16) & 0x0FF) == r->GetId() ) NoteOff(r->Box, ton_auf_kanal[i].id % 256, 64, r, ton_auf_kanal[i].id >> 24); }
void OutMidiPort::ReadData | ( | wxConfigBase * | config | ) | [virtual] |
Erneute Implementation von Device.
Definiert in Zeile 567 der Datei DevMidi.cpp.
Benutzt _() und bending_range.
{ bending_range = config->Read(_("Bending_Range"), (long)bending_range); }
void OutMidiPort::Save | ( | tree_storage & | config, |
const Route * | route | ||
) | [virtual] |
Save route settings (filter settings) for a given route.
Some route settings (e.g. filter settings) are device type specific. This function saves them in a tree storage. config (tree_storage *) Storage class, where the data will be saved. route (Route *) Route whos data shall be saved.
Implementiert Device.
Definiert in Zeile 158 der Datei DevMidi.cpp.
Benutzt Route::OFrom, Route::ONoDrum, Route::OTo und tree_storage::Write().
void OutMidiPort::Save | ( | tree_storage & | config | ) | [virtual] |
Save current device settings in a tree storage.
config (tree_storage) storage class, where the data will be saved.
Implementiert Device.
Definiert in Zeile 145 der Datei DevMidi.cpp.
Benutzt bending_range, Device::DevId, Device::Name und tree_storage::Write().
void OutMidiPort::SetBendingRange | ( | int | r | ) | [inline] |
Definiert in Zeile 132 der Datei DevMidi.h.
Benutzt bending_range.
Wird benutzt von MutOutputMidiDeviceShape::readDialog().
{ bending_range = r; }
virtual void OutMidiPort::SetDevId | ( | int | id | ) | [inline, virtual] |
Erneute Implementation von Device.
Definiert in Zeile 127 der Datei DevMidi.h.
Benutzt Device::DevId, RtMidiOut::getPortName(), muT und Device::Name.
Wird benutzt von MutOutputMidiDeviceShape::readDialog().
void OutMidiPort::Sustain | ( | char | on, |
int | channel | ||
) | [virtual] |
Implementiert OutDevice.
Definiert in Zeile 490 der Datei DevMidi.cpp.
Benutzt Cd, DEBUGLOG, MIDI_OUT3, ChannelData::Sustain und ton_auf_kanal.
Wird benutzt von NoteOn() und NotesCorrect().
{ DEBUGLOG (other, _T("")); DWORD chan = channel; // Midi has unsigned channels for (int i = 0; i < 16; i++) if ( ton_auf_kanal[i].id && (ton_auf_kanal[i].id >> 24) == chan ) { MIDI_OUT3(0xB0+i, 64, on); Cd[i].Sustain = on; } }
void OutMidiPort::WriteData | ( | wxConfigBase * | config | ) | [virtual] |
Erneute Implementation von Device.
Definiert in Zeile 573 der Datei DevMidi.cpp.
Benutzt _() und bending_range.
{ config->Write(_("Bending_Range"), (long)bending_range); }
int OutMidiPort::bending_range [private] |
Definiert in Zeile 61 der Datei DevMidi.h.
Wird benutzt von GetBendingRange(), Load(), NotesCorrect(), ReadData(), Save(), SetBendingRange() und WriteData().
ChannelData OutMidiPort::Cd[16] [private] |
HMIDIOUT OutMidiPort::hMidiOut [private] |
char OutMidiPort::KeyDir[16] [private] |
int OutMidiPort::nKeyOn [private] |
TonAufKanal OutMidiPort::ton_auf_kanal[16] [private] |