From: <pst...@us...> - 2008-05-19 03:57:58
|
Revision: 545 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=545&view=rev Author: pstieber Date: 2008-05-18 20:57:57 -0700 (Sun, 18 May 2008) Log Message: ----------- 1. Renamed JZEvent::Stat to JZEvent::mStat, made it protected, and added an accessor. 2. Made JZEvent::mClock protected. 3. Renamed JZEvent::Device to JZEvent::mDevice. Renamed e to pEvent in a few places. 4. Updated class and comment headers in Player.cpp. Modified Paths: -------------- trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/AsciiMidiFile.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Events.cpp trunk/jazz/src/Events.h trunk/jazz/src/Filter.h trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/Player.cpp trunk/jazz/src/StandardFile.cpp trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-05-19 00:59:59 UTC (rev 544) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-05-19 03:57:57 UTC (rev 545) @@ -402,17 +402,17 @@ // 0 = event successfully sent to driver // 1 = try again later //----------------------------------------------------------------------------- -int tAlsaPlayer::OutEvent(JZEvent *e, int now) +int tAlsaPlayer::OutEvent(JZEvent* pEvent, int now) { int rc = 0; snd_seq_event_t ev; memset(&ev, 0, sizeof(ev)); - switch (e->Stat) + switch (pEvent->GetStat()) { case StatKeyOn: { - tKeyOn *k = e->IsKeyOn(); - set_event_header(&ev, e->GetClock(), SND_SEQ_EVENT_NOTEON); + tKeyOn *k = pEvent->IsKeyOn(); + set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_NOTEON); ev.data.note.channel = k->Channel; ev.data.note.note = k->mKey; ev.data.note.velocity = k->mVelocity; @@ -422,8 +422,8 @@ case StatKeyOff: { - tKeyOff *k = e->IsKeyOff(); - set_event_header(&ev, e->GetClock(), SND_SEQ_EVENT_NOTEOFF); + tKeyOff *k = pEvent->IsKeyOff(); + set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_NOTEOFF); ev.data.note.channel = k->Channel; ev.data.note.note = k->Key; ev.data.note.velocity = k->OffVeloc; @@ -433,8 +433,8 @@ case StatProgram: { - tProgram *k = e->IsProgram(); - set_event_header(&ev, e->GetClock(), SND_SEQ_EVENT_PGMCHANGE); + tProgram *k = pEvent->IsProgram(); + set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_PGMCHANGE); ev.data.control.channel = k->Channel; ev.data.control.value = k->Program; rc = write(&ev, now); @@ -443,8 +443,8 @@ case StatKeyPressure: { - tKeyPressure *k = e->IsKeyPressure(); - set_event_header(&ev, e->GetClock(), SND_SEQ_EVENT_KEYPRESS); + tKeyPressure *k = pEvent->IsKeyPressure(); + set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_KEYPRESS); ev.data.note.channel = k->Channel; ev.data.note.note = k->Key; ev.data.note.velocity = k->Value; @@ -454,8 +454,8 @@ case StatChnPressure: { - tChnPressure *k = e->IsChnPressure(); - set_event_header(&ev, e->GetClock(), SND_SEQ_EVENT_CHANPRESS); + tChnPressure *k = pEvent->IsChnPressure(); + set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_CHANPRESS); ev.data.control.channel = k->Channel; ev.data.control.value = k->Value; rc = write(&ev, now); @@ -464,8 +464,8 @@ case StatControl: { - tControl *k = e->IsControl(); - set_event_header(&ev, e->GetClock(), SND_SEQ_EVENT_CONTROLLER); + tControl *k = pEvent->IsControl(); + set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_CONTROLLER); ev.data.control.channel = k->Channel; ev.data.control.param = k->mControl; ev.data.control.value = k->mValue; @@ -475,8 +475,8 @@ case StatPitch: { - tPitch *k = e->IsPitch(); - set_event_header(&ev, e->GetClock(), SND_SEQ_EVENT_PITCHBEND); + tPitch *k = pEvent->IsPitch(); + set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_PITCHBEND); ev.data.control.channel = k->Channel; ev.data.control.value = k->Value; rc = write(&ev, now); @@ -485,9 +485,9 @@ case StatSetTempo: { - int bpm = e->IsSetTempo()->GetBPM(); + int bpm = pEvent->IsSetTempo()->GetBPM(); int us = (int)( 60.0E6 / (double)bpm ); - set_event_header(&ev, e->GetClock(), SND_SEQ_EVENT_TEMPO); + set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_TEMPO); snd_seq_ev_set_queue_tempo(&ev, queue, us); rc = write(&ev, now); } @@ -495,12 +495,12 @@ case StatSysEx: { - tSysEx *s = e->IsSysEx(); + tSysEx *s = pEvent->IsSysEx(); // prepend 0xf0 char *buf = new char[s->Length + 1]; buf[0] = 0xF0; memcpy(buf + 1, s->mpData, s->Length); - set_event_header(&ev, e->GetClock(), s->Length + 1, buf); + set_event_header(&ev, pEvent->GetClock(), s->Length + 1, buf); rc = write(&ev, now); delete [] buf; } Modified: trunk/jazz/src/AsciiMidiFile.cpp =================================================================== --- trunk/jazz/src/AsciiMidiFile.cpp 2008-05-19 00:59:59 UTC (rev 544) +++ trunk/jazz/src/AsciiMidiFile.cpp 2008-05-19 03:57:57 UTC (rev 545) @@ -164,7 +164,7 @@ { tChannelEvent *ce; - fprintf(mpFd, "%6d %02x ", pEvent->GetClock(), pEvent->Stat); + fprintf(mpFd, "%6d %02x ", pEvent->GetClock(), pEvent->GetStat()); if ((ce = pEvent->IsChannelEvent()) != 0) { fprintf(mpFd, "%2d ", ce->Channel); Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2008-05-19 00:59:59 UTC (rev 544) +++ trunk/jazz/src/Dialogs.cpp 2008-05-19 03:57:57 UTC (rev 545) @@ -1361,7 +1361,7 @@ tEventDlg *dlg = 0; const char* str = 0; - switch (e->Stat) + switch (e->GetStat()) { case StatKeyOn: if (t->GetAudioMode()) Modified: trunk/jazz/src/Events.cpp =================================================================== --- trunk/jazz/src/Events.cpp 2008-05-19 00:59:59 UTC (rev 544) +++ trunk/jazz/src/Events.cpp 2008-05-19 03:57:57 UTC (rev 545) @@ -158,7 +158,7 @@ //----------------------------------------------------------------------------- int tGetMidiBytes::Write(JZEvent* pEvent, unsigned char* pData, int Length) { - int Stat = pEvent->Stat; + int Stat = pEvent->GetStat(); switch (Stat) { Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-05-19 00:59:59 UTC (rev 544) +++ trunk/jazz/src/Events.h 2008-05-19 03:57:57 UTC (rev 545) @@ -334,9 +334,13 @@ } #endif - unsigned char Stat; - int mClock; // should be protected ... + public: + unsigned char GetStat() const + { + return mStat; + } + int GetClock() const { return mClock & ~KILLED_CLOCK; @@ -353,11 +357,11 @@ BROADCAST_DEVICE = 0 }; - JZEvent(int clk, unsigned char sta) + JZEvent(int Clock, unsigned char Stat) { - mClock = clk; - Stat = sta; - Device = BROADCAST_DEVICE; + mClock = Clock; + mStat = Stat; + mDevice = BROADCAST_DEVICE; #ifdef E_DBUG Magic = MAGIC; #endif @@ -493,17 +497,23 @@ int GetDevice() const { - return Device; + return mDevice; } - void SetDevice(int d) + void SetDevice(int Device) { - Device = d; + mDevice = Device; } + protected: + + unsigned char mStat; + + int mClock; + private: - int Device; + int mDevice; }; @@ -898,7 +908,7 @@ virtual JZEvent* Copy() const { edb(); - return new tMetaEvent(mClock, Stat, mpData, Length); + return new tMetaEvent(mClock, mStat, mpData, Length); } }; Modified: trunk/jazz/src/Filter.h =================================================================== --- trunk/jazz/src/Filter.h 2008-05-19 00:59:59 UTC (rev 544) +++ trunk/jazz/src/Filter.h 2008-05-19 03:57:57 UTC (rev 545) @@ -84,10 +84,10 @@ int Value = pEvent->GetValue(); for (int i = 0; i < nFltEvents; ++i) { - if (pEvent->Stat == FltEvents[i].Stat) + if (pEvent->GetStat() == FltEvents[i].Stat) { // SN++ Aftertouch gehoert eigendlich zu KeyOn Events. - if (pEvent->Stat == StatKeyPressure) + if (pEvent->GetStat() == StatKeyPressure) { int aval = pEvent->IsKeyPressure()->Key; return @@ -95,17 +95,17 @@ FltEvents[i].FromValue <= aval && aval <= FltEvents[i].ToValue; } - if (pEvent->Stat == StatTimeSignat) + if (pEvent->GetStat() == StatTimeSignat) { return FltEvents[i].Selected; } // SN++ - if (pEvent->Stat == StatChnPressure) + if (pEvent->GetStat() == StatChnPressure) { return FltEvents[i].Selected; } - if (pEvent->Stat == StatSysEx) + if (pEvent->GetStat() == StatSysEx) { return FltEvents[i].Selected; } Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2008-05-19 00:59:59 UTC (rev 544) +++ trunk/jazz/src/PianoWindow.cpp 2008-05-19 03:57:57 UTC (rev 545) @@ -1420,7 +1420,7 @@ while (pEvent) { - if (pEvent->Stat == Stat) + if (pEvent->GetStat() == Stat) { int Pitch = pEvent->GetPitch(); int Length = pEvent->GetLength(); @@ -2258,7 +2258,7 @@ //----------------------------------------------------------------------------- int JZPianoWindow::IsVisible(JZEvent* pEvent) { - switch (pEvent->Stat) + switch (pEvent->GetStat()) { case StatKeyOn: return mVisibleKeyOn; Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-05-19 00:59:59 UTC (rev 544) +++ trunk/jazz/src/Player.cpp 2008-05-19 03:57:57 UTC (rev 545) @@ -71,38 +71,48 @@ using namespace std; -// ------------------------- tDeviceList -------------------------- - - +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tDeviceList::tDeviceList() : mDeviceNames() { } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tDeviceList::~tDeviceList() { } -// ------------------------- tPlayLoop -------------------------- - +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tPlayLoop::tPlayLoop() : mStartClock(0), mStopClock(0) { } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tPlayLoop::Reset() { mStartClock = mStopClock = 0; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tPlayLoop::Set(long Start, long Stop) { mStartClock = Start; mStopClock = Stop; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- long tPlayLoop::Ext2IntClock(long Clock) { if (mStopClock) @@ -112,12 +122,17 @@ return Clock; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- long tPlayLoop::Int2ExtClock(long Clock) { return Clock; } -// Copy events from song to output buffer. +//----------------------------------------------------------------------------- +// Description: +// Copy events from the passed song to output buffer. +//----------------------------------------------------------------------------- void tPlayLoop::PrepareOutput( tEventArray* buf, JZSong* pSong, @@ -160,9 +175,10 @@ } } -// ------------------------- JZPlayer --------------------- - - +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- JZPlayer::JZPlayer(JZSong* pSong) : mSamples(pSong->GetTicksPerQuarter() * pSong->Speed()) { @@ -176,17 +192,22 @@ rec_info = 0; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- JZPlayer::~JZPlayer() { delete PlayLoop; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZPlayer::ShowError() { wxMessageBox("could not install driver", "Error", wxOK); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZPlayer::StartPlay(long Clock, long LoopClock, int Continue) { #ifdef DEBUG_PLAYER_STARTPLAY @@ -433,10 +454,10 @@ } // if !Continue t = Song->GetTrack(0); - JZEvent *e = t->GetCurrentTempo(Clock); - if (e) + JZEvent* pEvent = t->GetCurrentTempo(Clock); + if (pEvent) { - OutNow(e); + OutNow(pEvent); } // Send songpointer? @@ -473,7 +494,8 @@ Playing = true; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZPlayer::StopPlay() { // Stop the wxTimer. @@ -492,10 +514,10 @@ if (Track) { tEventIterator Iterator(Track); - JZEvent *e = Iterator.First(); - while (e && e->GetClock() < Clock + 100) + JZEvent* pEvent = Iterator.First(); + while (pEvent && pEvent->GetClock() < Clock + 100) { - tKeyOn* pKeyOn = e->IsKeyOn(); + tKeyOn* pKeyOn = pEvent->IsKeyOn(); if (pKeyOn) { if (pKeyOn->GetClock() + pKeyOn->mLength >= Clock - 100) @@ -505,7 +527,7 @@ OutNow(&off); } } - e = Iterator.Next(); + pEvent = Iterator.Next(); } } } @@ -513,7 +535,8 @@ JZProjectManager::Instance()->NewPlayPosition(-1); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZPlayer::Notify() { // called by timer @@ -560,22 +583,24 @@ } } - +//----------------------------------------------------------------------------- +// Description: +// Try to send all events up to OutClock to device. +//----------------------------------------------------------------------------- void JZPlayer::FlushToDevice() -// try to send all events up to OutClock to device { int BufferFull = 0; tEventIterator Iterator(&mPlayBuffer); - JZEvent *e = Iterator.Range(0, OutClock); - while (!BufferFull && e) + JZEvent* pEvent = Iterator.Range(0, OutClock); + while (!BufferFull && pEvent) { - if (OutEvent(e) != 0) + if (OutEvent(pEvent) != 0) BufferFull = 1; else { - e->Kill(); - e = Iterator.Next(); + pEvent->Kill(); + pEvent = Iterator.Next(); } } @@ -584,7 +609,8 @@ mPlayBuffer.Cleanup(0); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZPlayer::AllNotesOff(int Reset) { tControl NoteOff(0, 0, 0x78, 0); @@ -616,8 +642,8 @@ } } - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZPlayer::OutNow(JZTrack *t, tParam *r) { OutNow(t, &r->mMsb); @@ -627,42 +653,47 @@ OutNow(t, &r->mResetLsb); } -// ---------------------------------------------------------------------------------------------- -// MPU-Player -// ---------------------------------------------------------------------------------------------- - #ifdef DEV_MPU401 +//***************************************************************************** +// MPU-Player +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tMpuPlayer::tMpuPlayer(JZSong* pSong) : JZPlayer(pSong) { - poll_millisec = 25; - midinethost = getenv("MIDINETHOST"); - if (!midinethost || !strlen(midinethost)) { - midinethost = "localhost"; - } - midinetservice = getenv("MIDINETSERVICE"); - if (!midinetservice || !strlen(midinetservice)) { - midinetservice = MIDINETSERVICE; - } - dev = midinetconnect( midinethost, midinetservice ); + poll_millisec = 25; + midinethost = getenv("MIDINETHOST"); + if (!midinethost || !strlen(midinethost)) + { + midinethost = "localhost"; + } + midinetservice = getenv("MIDINETSERVICE"); + if (!midinetservice || !strlen(midinetservice)) + { + midinetservice = MIDINETSERVICE; + } + dev = midinetconnect( midinethost, midinetservice ); } - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tMpuPlayer::~tMpuPlayer() { close(dev); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tMpuPlayer::Installed() { return dev >= 0; } - #if DB_WRITE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int dwrite(int dev, const char *buf, int size) { int i, written; @@ -675,13 +706,17 @@ } printf("W: "); for (i = 0; i < written; i++) + { printf("%02x ", (unsigned char)buf[i]); + } putchar('\n'); if (written != size) { printf("L: "); for (i = written; i < size; i++) + { printf("%02x ", (unsigned char)buf[i]); + } putchar('\n'); } fflush(stdout); @@ -689,6 +724,8 @@ } #endif +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tMpuPlayer::StartPlay(long IntClock, long LoopClock, int Continue) { long ExtClock = PlayLoop->Int2ExtClock(IntClock); @@ -740,9 +777,10 @@ clock_to_host_counter = 0; ActiveTrack = 0; - for (int i = 0; i < ACTIVE_TRACKS; i++) { - TrackClock[i] = ExtClock; - TrackRunningStatus[i] = 0; + for (int i = 0; i < ACTIVE_TRACKS; i++) + { + TrackClock[i] = ExtClock; + TrackRunningStatus[i] = 0; } // Setup Timebase @@ -765,49 +803,50 @@ JZPlayer::StartPlay(IntClock, LoopClock, Continue); // Supress realtime messages to MIDI Out port? - if (!Config(C_RealTimeOut)) { - char realtime[2]; - realtime[0] = CMD+1; - realtime[1] = 0x32; - write_ack_mpu( realtime, 2 ); + if (!Config(C_RealTimeOut)) + { + char realtime[2]; + realtime[0] = CMD + 1; + realtime[1] = 0x32; + write_ack_mpu(realtime, 2); } // What is the clock source ? char clocksource[2]; clocksource[0] = CMD+1; - switch (Config(C_ClockSource)) { - case CsInt: - clocksource[1] = 0x80; - play = play1; - playsize = sizeof( play1 ); - break; - case CsFsk: - clocksource[1] = 0x81; - play = play1; - playsize = sizeof( play1 ); - break; - case CsMidi: - clocksource[1] = 0x82; - play = play2; - playsize = sizeof( play2 ); - break; - default: - clocksource[1] = 0x80; - play = play1; - playsize = sizeof( play1 ); - break; + switch (Config(C_ClockSource)) + { + case CsInt: + clocksource[1] = 0x80; + play = play1; + playsize = sizeof( play1 ); + break; + case CsFsk: + clocksource[1] = 0x81; + play = play1; + playsize = sizeof( play1 ); + break; + case CsMidi: + clocksource[1] = 0x82; + play = play2; + playsize = sizeof( play2 ); + break; + default: + clocksource[1] = 0x80; + play = play1; + playsize = sizeof( play1 ); + break; } write_ack_mpu(clocksource, 2); JZPlayer::Notify(); // Start play - write_ack_mpu( play, playsize ); - + write_ack_mpu(play, playsize); } - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tMpuPlayer::StopPlay() { static const char stop = RES; @@ -822,25 +861,33 @@ RecdBuffer.Keyoff2Length(); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tMpuPlayer::SetHardThru(int on, int idummy, int odummy) { - char midithru[2]; midithru[0] = CMD+1; if (on) + { midithru[1] = 0x89; + } else + { midithru[1] = 0x88; + } write_ack_mpu( midithru, 2 ); - } -int tMpuPlayer::OutEvent(JZEvent *e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int tMpuPlayer::OutEvent(JZEvent* pEvent) { if (!PlyBytes.WriteFile(dev)) + { return 1; // buffer full + } - int Stat = e->Stat; + int Stat = pEvent->GetStat(); switch (Stat) { @@ -851,156 +898,167 @@ case StatProgram: case StatChnPressure: case StatPitch: - { - tGetMidiBytes midi; - int i; - tChannelEvent *c; + { + tGetMidiBytes midi; + int i; + tChannelEvent *c; - e->Write(midi); - Stat = midi.Buffer[0]; // Status + Channel + pEvent->Write(midi); + Stat = midi.Buffer[0]; // Status + Channel - OutBreak(e->GetClock()); + OutBreak(pEvent->GetClock()); - if ( (c = e->IsChannelEvent()) != 0 ) { - switch (c->Channel) { - case 0: - case 3: - ActiveTrack = 5; - break; - case 1: - case 4: - ActiveTrack = 4; - break; - case 2: - case 5: - ActiveTrack = 3; - break; - case 6: - case 10: - case 13: - ActiveTrack = 2; - break; - case 9: - ActiveTrack = 6; - break; - case 7: - case 11: - case 14: - ActiveTrack = 1; - break; - case 8: - case 12: - case 15: - ActiveTrack = 0; - break; - default: - ActiveTrack = 6; - break; - } + if ((c = pEvent->IsChannelEvent()) != 0) + { + switch (c->Channel) + { + case 0: + case 3: + ActiveTrack = 5; + break; + case 1: + case 4: + ActiveTrack = 4; + break; + case 2: + case 5: + ActiveTrack = 3; + break; + case 6: + case 10: + case 13: + ActiveTrack = 2; + break; + case 9: + ActiveTrack = 6; + break; + case 7: + case 11: + case 14: + ActiveTrack = 1; + break; + case 8: + case 12: + case 15: + ActiveTrack = 0; + break; + default: + ActiveTrack = 6; + break; } - else { - // Not channel event => play on track #6 - ActiveTrack = 6; - } + } + else + { + // Not channel event => play on track #6 + ActiveTrack = 6; + } - long Time = e->GetClock() - TrackClock[ActiveTrack]; - assert(Time < 240); + long Time = pEvent->GetClock() - TrackClock[ActiveTrack]; + assert(Time < 240); - if (Stat != TrackRunningStatus[ActiveTrack]) - { - PlyBytes.Put(TRK + midi.nBytes + 1 + 1); - PlyBytes.Put(ActiveTrack); - PlyBytes.Put(Time); - PlyBytes.Put(Stat); - TrackRunningStatus[ActiveTrack] = Stat; - } - else - { - PlyBytes.Put(TRK + midi.nBytes + 1); - PlyBytes.Put(ActiveTrack); - PlyBytes.Put(Time); - } - for (i = 1; i < midi.nBytes; i++) - PlyBytes.Put(midi.Buffer[i]); - - TrackClock[ActiveTrack] = e->GetClock(); - return 0; + if (Stat != TrackRunningStatus[ActiveTrack]) + { + PlyBytes.Put(TRK + midi.nBytes + 1 + 1); + PlyBytes.Put(ActiveTrack); + PlyBytes.Put(Time); + PlyBytes.Put(Stat); + TrackRunningStatus[ActiveTrack] = Stat; } + else + { + PlyBytes.Put(TRK + midi.nBytes + 1); + PlyBytes.Put(ActiveTrack); + PlyBytes.Put(Time); + } + for (i = 1; i < midi.nBytes; i++) + PlyBytes.Put(midi.Buffer[i]); + TrackClock[ActiveTrack] = pEvent->GetClock(); + return 0; + } + case StatSetTempo: case StatSysEx: + { + if (pEvent->GetClock() > 0) { - if (e->GetClock() > 0) - { - OutOfBandEvents.Put(e->Copy()); - } - return 0; + OutOfBandEvents.Put(pEvent->Copy()); } + return 0; + } default: // Meterchange etc - return 0; - break; + return 0; + break; } } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tMpuPlayer::OutBreak() { // send a break to the driver starting at PlyBytes.GetClock() and ending at OutClock if (!PlyBytes.WriteFile(dev)) + { return; + } (void)OutBreak(OutClock); PlyBytes.WriteFile(dev); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tMpuPlayer::OutBreak(long BreakOver) { -int OverFlow = 1; + int OverFlow = 1; - while (OverFlow) { - OverFlow = 0; - for (int i = 0; i < ACTIVE_TRACKS; i++) { - if ( (BreakOver - TrackClock[i]) >= 240 ) { - PlyBytes.Put(TRK+1+1); - PlyBytes.Put( i ); - PlyBytes.Put(0xf8); - TrackClock[i] += 240; - OverFlow = 1; - } - } + while (OverFlow) + { + OverFlow = 0; + for (int i = 0; i < ACTIVE_TRACKS; i++) + { + if ((BreakOver - TrackClock[i]) >= 240) + { + PlyBytes.Put(TRK + 1 + 1); + PlyBytes.Put(i); + PlyBytes.Put(0xf8); + TrackClock[i] += 240; + OverFlow = 1; + } } + } } - - -void tMpuPlayer::OutNow(JZEvent *e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void tMpuPlayer::OutNow(JZEvent* pEvent) { // send event to driver immediately regardless of events remaining // in the play-queue. int i, n = 0; tGetMidiBytes midi; - if (e->Write(midi) == 0) + if (pEvent->Write(midi) == 0) { char *buf = new char[midi.nBytes + 3]; buf[n++] = CMD+1; buf[n++] = 0xd7; buf[n++] = DAT+midi.nBytes; for (i = 0; i < midi.nBytes; i++) + { buf[n++] = midi.Buffer[i]; + } write_noack_mpu(buf, n); delete[] buf; } - else // special event { - switch (e->Stat) + switch (pEvent->GetStat()) { case StatSetTempo: { char cmd[4]; - tSetTempo *s = (tSetTempo *)e; + tSetTempo *s = (tSetTempo *)pEvent; int bpm = s->GetBPM(); cmd[0] = CMD+1; cmd[1] = 0xE0; @@ -1011,31 +1069,35 @@ break; case StatSysEx: { - n = 0; - tSysEx *s = (tSysEx *) e; - char *sysex = new char[s->Length+4]; - sysex[n++] = CMD+1; - sysex[n++] = 0xdf; - sysex[n++] = DAT + s->Length + 1; - sysex[n++] = StatSysEx; - for (i = 0; i < s->Length; i++) - sysex[n++] = s->Data[i]; - write_noack_mpu(sysex, n); - delete[] sysex; + n = 0; + tSysEx *s = (tSysEx *) pEvent; + char *sysex = new char[s->Length+4]; + sysex[n++] = CMD+1; + sysex[n++] = 0xdf; + sysex[n++] = DAT + s->Length + 1; + sysex[n++] = StatSysEx; + for (i = 0; i < s->Length; i++) + { + sysex[n++] = s->Data[i]; + } + write_noack_mpu(sysex, n); + delete[] sysex; } case StatSongPtr: { - n = 0; - tSongPtr *s = (tSongPtr *) e; - char *common = new char[s->Length+4]; - common[n++] = CMD+1; - common[n++] = 0xdf; - common[n++] = DAT + s->Length + 1; - common[n++] = StatSongPtr; - for (i = 0; i < s->Length; i++) - common[n++] = s->Data[i]; - write_noack_mpu(common, n); - delete[] common; + n = 0; + tSongPtr *s = (tSongPtr *) pEvent; + char *common = new char[s->Length+4]; + common[n++] = CMD+1; + common[n++] = 0xdf; + common[n++] = DAT + s->Length + 1; + common[n++] = StatSongPtr; + for (i = 0; i < s->Length; i++) + { + common[n++] = s->Data[i]; + } + write_noack_mpu(common, n); + delete[] common; } break; @@ -1045,20 +1107,21 @@ } } - +//----------------------------------------------------------------------------- +// try to send all out of band events up to Clock to device +//----------------------------------------------------------------------------- void tMpuPlayer::FlushOutOfBand(long Clock) -// try to send all out of band events up to Clock to device { tEventIterator Iterator(&OutOfBandEvents); - JZEvent *e = Iterator.Range(0, Clock); - while (e) + JZEvent* pEvent = Iterator.Range(0, Clock); + while (pEvent) { - switch (e->Stat) + switch (pEvent->GetStat()) { case StatSetTempo: { char cmd[4]; - tSetTempo *s = (tSetTempo *)e; + tSetTempo *s = (tSetTempo *)pEvent; int bpm = s->GetBPM(); cmd[0] = CMD+1; cmd[1] = 0xE0; @@ -1070,7 +1133,7 @@ case StatSysEx: { int n = 0; - tSysEx *s = (tSysEx *) e; + tSysEx *s = (tSysEx *) pEvent; char *sysex = new char[s->Length+4]; sysex[n++] = CMD+1; sysex[n++] = 0xdf; @@ -1084,14 +1147,15 @@ default: break; } - e->Kill(); - e = Iterator.Next(); + pEvent->Kill(); + pEvent = Iterator.Next(); } OutOfBandEvents.Cleanup(0); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- long tMpuPlayer::GetRealTimeClock() { static int receiving_song_ptr = 0; @@ -1167,7 +1231,8 @@ return playclock; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- long tMpuPlayer::GetRecordedData() { int c, i; @@ -1196,7 +1261,7 @@ { unsigned char c1, c2; int Channel; - JZEvent *e = 0; + JZEvent* pEvent = 0; if (c & 0x80) { @@ -1211,39 +1276,43 @@ { case StatKeyOff: c2 = recbuf[i++]; // SN++ added veloc - e = new tKeyOff(RecBytes.Clock, Channel, c1, c2); - e = new tKeyOff(RecBytes.Clock, Channel, c1); + pEvent = new tKeyOff(RecBytes.Clock, Channel, c1, c2); + pEvent = new tKeyOff(RecBytes.Clock, Channel, c1); break; case StatKeyOn: c2 = recbuf[i++]; if (!c2) - e = new tKeyOff(RecBytes.Clock, Channel, c1); + { + pEvent = new tKeyOff(RecBytes.Clock, Channel, c1); + } else - e = new tKeyOn(RecBytes.Clock, Channel, c1, c2); + { + pEvent = new tKeyOn(RecBytes.Clock, Channel, c1, c2); + } break; // #if 0 case StatKeyPressure: c2 = recbuf[i++]; - e = new tKeyPressure(RecBytes.Clock, Channel, c1, c2); + pEvent = new tKeyPressure(RecBytes.Clock, Channel, c1, c2); break; case StatChnPressure: - e = new tChnPressure(RecBytes.Clock, Channel, c1); + pEvent = new tChnPressure(RecBytes.Clock, Channel, c1); break; case StatControl: c2 = recbuf[i++]; - e = new tControl(RecBytes.Clock, Channel, c1, c2); + pEvent = new tControl(RecBytes.Clock, Channel, c1, c2); break; case StatProgram: - e = new tProgram(RecBytes.Clock, Channel, c1); + pEvent = new tProgram(RecBytes.Clock, Channel, c1); break; case StatPitch: c2 = recbuf[i++]; - e = new tPitch(RecBytes.Clock, Channel, c1, c2); + pEvent = new tPitch(RecBytes.Clock, Channel, c1, c2); break; default: @@ -1251,13 +1320,14 @@ break; } - if (e) + if (pEvent) { - e->Clock = PlayLoop->Ext2IntClock(e->Clock); - RecdBuffer.Put(e); + pEvent->Clock = PlayLoop->Ext2IntClock(pEvent->Clock); + RecdBuffer.Put(pEvent); } } - else if (c == 0xfc) { + else if (c == 0xfc) + { // Data end mark } else @@ -1273,12 +1343,12 @@ #endif // DEV_MPU401 -// **************************************************************** -// /dev/sequencer2 -// **************************************************************** - #ifdef DEV_SEQUENCER2 +//***************************************************************************** +// /dev/sequencer2 +//***************************************************************************** + // SN-- SEQ_DEFINEBUF (32768); #define sequencer_buffer 65536 SEQ_DEFINEBUF (sequencer_buffer); // 64K @@ -1286,6 +1356,8 @@ int seqfd = -1; int mididev = -1; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void seqbuf_dump(void) { if (_seqbufptr) @@ -1309,10 +1381,12 @@ memmove(_seqbuf, _seqbuf + size, _seqbufptr); } } -#define seqbuf_empty() (_seqbufptr == 0) + +#define seqbuf_empty() (_seqbufptr == 0) #define seqbuf_clear() (_seqbufptr = 0) - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void seqbuf_flush_last_event() { _seqbufptr -= 8; @@ -1320,8 +1394,11 @@ perror("ioctl flush_last"); } -// --------------------- voxware midi through ------------------------ - +//***************************************************************************** +// voxware midi through +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tOSSThru::tOSSThru() { int time_base = 120; @@ -1335,7 +1412,8 @@ Start(5); // poll every 5 ms } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tOSSThru::~tOSSThru() { Stop(); @@ -1343,7 +1421,8 @@ seqbuf_dump(); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tOSSThru::Notify() { unsigned char buf[128]; @@ -1365,13 +1444,15 @@ } if (_seqbufptr) + { seqbuf_dump(); + } } - -// ------------------------- tSeq2Player --------------------- - - +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tSeq2Player::tSeq2Player(JZSong* pSong) : JZPlayer(pSong) { @@ -1426,22 +1507,25 @@ } } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSeq2Player::Installed() { return seqfd >= 0 && mididev >= 0; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tSeq2Player::~tSeq2Player() { delete through; if (seqfd > 0) close(seqfd); seqfd = -1; - } +} - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSeq2Player::FindMidiDevice() { struct synth_info si; @@ -1507,6 +1591,8 @@ } } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSeq2Player::SetSoftThru(int on, int idummy, int odummy) { gpConfig->Put(C_SoftThru, on); @@ -1527,20 +1613,21 @@ } } - -int tSeq2Player::OutEvent(JZEvent *e, int now) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int tSeq2Player::OutEvent(JZEvent* pEvent, int now) { if (!now) { - OutBreak(e->GetClock()); + OutBreak(pEvent->GetClock()); } - int Stat = e->Stat; + int Stat = pEvent->GetStat(); switch (Stat) { case StatKeyOn: { - tKeyOn* pKeyOn = e->IsKeyOn(); + tKeyOn* pKeyOn = pEvent->IsKeyOn(); SEQ_START_NOTE( mididev, pKeyOn->Channel, @@ -1552,7 +1639,7 @@ case StatKeyOff: { - tKeyOff* pKeyOff = e->IsKeyOff(); + tKeyOff* pKeyOff = pEvent->IsKeyOff(); SEQ_STOP_NOTE( mididev, pKeyOff->Channel, @@ -1563,7 +1650,7 @@ break; case StatProgram: { - tProgram *k = e->IsProgram(); + tProgram *k = pEvent->IsProgram(); SEQ_SET_PATCH(mididev, k->Channel, k->Program); if (now) seqbuf_flush_last_event(); } @@ -1572,7 +1659,7 @@ // SN++ Aftertouch case StatKeyPressure: { - tKeyPressure *k = e->IsKeyPressure(); + tKeyPressure *k = pEvent->IsKeyPressure(); SEQ_KEY_PRESSURE(mididev, k->Channel, k->Key, k->Value); if (now) seqbuf_flush_last_event(); } @@ -1581,7 +1668,7 @@ case StatChnPressure: { - tChnPressure *k = e->IsChnPressure(); + tChnPressure *k = pEvent->IsChnPressure(); SEQ_CHN_PRESSURE(mididev, k->Channel, k->Value); if (now) seqbuf_flush_last_event(); } @@ -1589,7 +1676,7 @@ case StatControl: { - tControl *k = e->IsControl(); + tControl *k = pEvent->IsControl(); SEQ_CONTROL(mididev, k->Channel, k->mControl, k->mValue); if (now) seqbuf_flush_last_event(); } @@ -1597,7 +1684,7 @@ case StatPitch: { - tPitch *k = e->IsPitch(); + tPitch *k = pEvent->IsPitch(); SEQ_BENDER(mididev, k->Channel, k->Value + 8192); if (now) seqbuf_flush_last_event(); } @@ -1605,7 +1692,7 @@ case StatSetTempo: { - int bpm = e->IsSetTempo()->GetBPM(); + int bpm = pEvent->IsSetTempo()->GetBPM(); if (now) { if (ioctl(seqfd, SNDCTL_TMR_TEMPO, &bpm) < 0) @@ -1614,7 +1701,7 @@ else { if (!GetAudioEnabled()) - if (e->GetClock() > 0) + if (pEvent->GetClock() > 0) SEQ_SET_TEMPO(bpm); } } @@ -1625,7 +1712,7 @@ if (now) { // todo - tSysEx *s = e->IsSysEx(); + tSysEx *s = pEvent->IsSysEx(); struct sysex_info *sysex = (struct sysex_info *)new char [sizeof(struct sysex_info) + s->Length + 1]; sysex->key = SYSEX_PATCH; @@ -1637,9 +1724,10 @@ delete [] (char *)sysex; } - else if (e->GetClock() > 0) { + else if (pEvent->GetClock() > 0) + { // OSS wants small packets with max 6 bytes - tSysEx *sx = e->IsSysEx(); + tSysEx *sx = pEvent->IsSysEx(); const int N = 6; int i, j; char buf[N]; @@ -1666,8 +1754,8 @@ return 0; } - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSeq2Player::OutBreak(long clock) { if (play_clock < clock) @@ -1688,13 +1776,16 @@ play_clock = clock; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSeq2Player::OutBreak() { OutBreak(OutClock); seqbuf_dump(); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSeq2Player::StartPlay(long Clock, long LoopClock, int Continue) { char buf[512]; @@ -1772,7 +1863,8 @@ seqbuf_dump(); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSeq2Player::StopPlay() { seqbuf_clear(); @@ -1796,20 +1888,21 @@ RecdBuffer.Keyoff2Length(); } - +//----------------------------------------------------------------------------- +// try to send all events up to OutClock to device +//----------------------------------------------------------------------------- void tSeq2Player::FlushToDevice() -// try to send all events up to OutClock to device { tEventIterator Iterator(&mPlayBuffer); - JZEvent *e = Iterator.Range(0, OutClock); - if (e) + JZEvent* pEvent = Iterator.Range(0, OutClock); + if (pEvent) { do { - OutEvent(e); - e->Kill(); - e = Iterator.Next(); - } while (e); + OutEvent(pEvent); + pEvent->Kill(); + pEvent = Iterator.Next(); + } while (pEvent); mPlayBuffer.Cleanup(0); } @@ -1817,7 +1910,8 @@ seqbuf_dump(); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- long tSeq2Player::GetRealTimeClock() { unsigned char buf[256]; @@ -1827,7 +1921,7 @@ int i = 0; while (i < size) { - JZEvent *e = 0; + JZEvent* pEvent = 0; switch(buf[i]) { @@ -1854,16 +1948,16 @@ //printf("got: chn %d, ctl %d, val %d\n", chn, ctl, val); switch(buf[i+2]) { case MIDI_CTL_CHANGE: - e = new tControl(0, chn, ctl, val); + pEvent = new tControl(0, chn, ctl, val); break; case MIDI_PGM_CHANGE: - e = new tProgram(0, chn, ctl); + pEvent = new tProgram(0, chn, ctl); break; case MIDI_CHN_PRESSURE: - e = new tChnPressure(0, chn, ctl); + pEvent = new tChnPressure(0, chn, ctl); break; case MIDI_PITCH_BEND: - e = new tPitch(0, chn, val - 8192); + pEvent = new tPitch(0, chn, val - 8192); break; } @@ -1882,18 +1976,23 @@ unsigned char chn = buf[i+3]; unsigned char key = buf[i+4]; unsigned char vel = buf[i+5]; - switch(buf[i+2]) { + switch(buf[i+2]) + { case MIDI_NOTEOFF: // SN++ added veloc - e = new tKeyOff(0, chn, key, vel); + pEvent = new tKeyOff(0, chn, key, vel); break; case MIDI_NOTEON: if (vel == 0) - e = new tKeyOff(0, chn, key); + { + pEvent = new tKeyOff(0, chn, key); + } else - e = new tKeyOn(0, chn, key, vel); + { + pEvent = new tKeyOn(0, chn, key, vel); + } break; case MIDI_KEY_PRESSURE: - e = new tKeyPressure(0, chn, key, vel); + pEvent = new tKeyPressure(0, chn, key, vel); break; } @@ -1913,11 +2012,11 @@ break; } - if (e) + if (pEvent) { - e->SetClock(PlayLoop->Ext2IntClock(recd_clock)); - RecdBuffer.Put(e); - e = 0; + pEvent->SetClock(PlayLoop->Ext2IntClock(recd_clock)); + RecdBuffer.Put(pEvent); + pEvent = 0; } } Modified: trunk/jazz/src/StandardFile.cpp =================================================================== --- trunk/jazz/src/StandardFile.cpp 2008-05-19 00:59:59 UTC (rev 544) +++ trunk/jazz/src/StandardFile.cpp 2008-05-19 03:57:57 UTC (rev 545) @@ -230,10 +230,10 @@ #if 0 printfxxo("%02X %02X ", pEvent->Clock, dif); - if (pEvent->Stat != 0x90) + if (pEvent->GetStat() != 0x90) { int i; - printf("%02X ", pEvent->Stat); + printf("%02X ", pEvent->GetStat()); for (i = 0; i < Length; i++) { printf("%02X ", Data[i]); @@ -242,7 +242,7 @@ } #endif - switch (pEvent->Stat) + switch (pEvent->GetStat()) { // KeyOff -> KeyOn mit Vel=0. Gives better Runningstatus! case StatKeyOff: @@ -281,7 +281,7 @@ // SN++ case StatChnPressure: - Stat = pEvent->Stat | pEvent->IsChannelEvent()->Channel; + Stat = pEvent->GetStat() | pEvent->IsChannelEvent()->Channel; if (Stat != RunningStatus) { RunningStatus = Stat; @@ -323,14 +323,14 @@ if (1) { int i; - printf("%02X ", pEvent->Stat); + printf("%02X ", pEvent->GetStat()); for (i = 0; i < Length; i++) printf("%02X ", Data[i]); putchar('\n'); } #endif - Stat = pEvent->Stat; + Stat = pEvent->GetStat(); RunningStatus = 0; *cp++ = 0xff; *cp++ = Stat; Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-19 00:59:59 UTC (rev 544) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-19 03:57:57 UTC (rev 545) @@ -210,48 +210,50 @@ } u; u.w = dw; - JZEvent *e = 0; + JZEvent* pEvent = 0; switch(u.c[0] & 0xf0) { case 0x80: - e = new tKeyOff(0, u.c[0] & 0x0f, u.c[1]); + pEvent = new tKeyOff(0, u.c[0] & 0x0f, u.c[1]); break; case 0x90: if (u.c[2]) - e = new tKeyOn(0, u.c[0] & 0x0f, u.c[1], u.c[2], 0); + pEvent = new tKeyOn(0, u.c[0] & 0x0f, u.c[1], u.c[2], 0); else - e = new tKeyOff(0, u.c[0] & 0x0f, u.c[1]); + pEvent = new tKeyOff(0, u.c[0] & 0x0f, u.c[1]); break; case 0xA0: - e = new tKeyPressure(0, u.c[0] & 0x0f, u.c[1], u.c[2]); + pEvent = new tKeyPressure(0, u.c[0] & 0x0f, u.c[1], u.c[2]); break; case 0xB0: if (u.c[1] != 0x7b) - e = new tControl(0, u.c[0] & 0x0f, u.c[1], u.c[2]); + { + pEvent = new tControl(0, u.c[0] & 0x0f, u.c[1], u.c[2]); + } break; case 0xC0: - e = new tProgram(0, u.c[0] & 0x0f, u.c[1]); + pEvent = new tProgram(0, u.c[0] & 0x0f, u.c[1]); break; case 0xD0: - e = new tChnPressure(0, u.c[0] & 0x0f, u.c[1]); + pEvent = new tChnPressure(0, u.c[0] & 0x0f, u.c[1]); break; case 0xE0: - e = new tPitch(0, u.c[0] & 0x0f, u.c[1], u.c[2]); + pEvent = new tPitch(0, u.c[0] & 0x0f, u.c[1], u.c[2]); break; } - return e; + return pEvent; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -DWORD JZWindowsPlayer::Event2Dword(JZEvent *e) +DWORD JZWindowsPlayer::Event2Dword(JZEvent* pEvent) { union { @@ -260,12 +262,12 @@ } u; u.w = 0; - int Stat = e->Stat; + int Stat = pEvent->GetStat(); switch (Stat) { case StatKeyOn: { - tKeyOn *k = e->IsKeyOn(); + tKeyOn *k = pEvent->IsKeyOn(); u.c[0] = 0x90 | k->Channel; u.c[1] = k->mKey; u.c[2] = k->mVelocity; @@ -274,7 +276,7 @@ case StatKeyOff: { - tKeyOff *k = e->IsKeyOff(); + tKeyOff *k = pEvent->IsKeyOff(); u.c[0] = 0x80 | k->Channel; u.c[1] = k->Key; u.c[2] = 0; @@ -283,7 +285,7 @@ case StatProgram: { - tProgram *k = e->IsProgram(); + tProgram *k = pEvent->IsProgram(); u.c[0] = 0xC0 | k->Channel; u.c[1] = k->Program; } @@ -291,7 +293,7 @@ case StatChnPressure: { - tChnPressure *k = e->IsChnPressure(); + tChnPressure *k = pEvent->IsChnPressure(); u.c[0] = 0xC0 | k->Channel; u.c[1] = k->Value; } @@ -299,7 +301,7 @@ case StatControl: { - tControl* pControl = e->IsControl(); + tControl* pControl = pEvent->IsControl(); u.c[0] = 0xB0 | pControl->Channel; u.c[1] = pControl->mControl; u.c[2] = pControl->mValue; @@ -308,7 +310,7 @@ case StatKeyPressure: { - tKeyPressure *k = e->IsKeyPressure(); + tKeyPressure *k = pEvent->IsKeyPressure(); u.c[0] = 0xA0 | k->Channel; u.c[1] = k->Key; u.c[2] = k->Value; @@ -317,7 +319,7 @@ case StatPitch: { - tPitch *k = e->IsPitch(); + tPitch *k = pEvent->IsPitch(); int v = k->Value + 8192; u.c[0] = 0xE0 | k->Channel; u.c[1] = (unsigned char)(v & 0x7F); @@ -339,11 +341,11 @@ case StatSetTempo: { - tSetTempo *t = e->IsSetTempo(); + tSetTempo *t = pEvent->IsSetTempo(); if (t && t->GetClock() > 0) { SetTempo( t->GetBPM(), t->GetClock() ); - OutOfBandEvents.Put( e->Copy() ); + OutOfBandEvents.Put(pEvent->Copy()); } } break; @@ -415,9 +417,9 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZWindowsPlayer::OutSysex(JZEvent *e, DWORD time) +int JZWindowsPlayer::OutSysex(JZEvent* pEvent, DWORD time) { - tSysEx *sx = e->IsSysEx(); + tSysEx *sx = pEvent->IsSysEx(); if (sx == 0) return 1; @@ -434,32 +436,32 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZWindowsPlayer::OutEvent(JZEvent *e) +int JZWindowsPlayer::OutEvent(JZEvent* pEvent) { - DWORD d = Event2Dword(e); + DWORD d = Event2Dword(pEvent); if (d) { - state->play_buffer.put(d, Clock2Time(e->GetClock())); + state->play_buffer.put(d, Clock2Time(pEvent->GetClock())); } - else if (e->IsSysEx() && (e->GetClock() > 0)) + else if (pEvent->IsSysEx() && (pEvent->GetClock() > 0)) { - OutSysex(e, Clock2Time(e->GetClock())); + OutSysex(pEvent, Clock2Time(pEvent->GetClock())); } return 0; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZWindowsMidiPlayer::OutEvent(JZEvent *e) +int JZWindowsMidiPlayer::OutEvent(JZEvent* pEvent) { - DWORD d = Event2Dword(e); + DWORD d = Event2Dword(pEvent); if (d) { - state->play_buffer.put(d, e->GetClock()); + state->play_buffer.put(d, pEvent->GetClock()); } - else if (e->IsSysEx() && (e->GetClock() > 0)) + else if (pEvent->IsSysEx() && (pEvent->GetClock() > 0)) { - OutSysex(e, e->GetClock()); + OutSysex(pEvent, pEvent->GetClock()); } return 0; } @@ -474,14 +476,14 @@ { midiOutShortMsg(state->hout, d); } - else if (pEvent->Stat == StatSetTempo) + else if (pEvent->GetStat() == StatSetTempo) { if (state->playing) { SetTempo(pEvent->IsSetTempo()->GetBPM(), OutClock); } } - else if (pEvent->Stat == StatSysEx) + else if (pEvent->GetStat() == StatSysEx) { tSysEx *s = pEvent->IsSysEx(); if (s->Length + 1 < maxSysLen) @@ -641,12 +643,16 @@ if (gpConfig->GetValue(C_RealTimeOut)) { - tMetaEvent *e; + tMetaEvent* pEvent; if (!Continue) - e = new tStartPlay( 0 ); + { + pEvent = new tStartPlay(0); + } else - e = new tContPlay( 0 ); - OutNow( e ); + { + pEvent = new tContPlay(0); + } + OutNow(pEvent); FillMidiClocks(mPlayBuffer.GetLastClock()); // also does a sort } @@ -709,9 +715,9 @@ JZPlayer::StopPlay(); if (gpConfig->GetValue(C_RealTimeOut)) { - tStopPlay *e = new tStopPlay(0); - OutNow( e ); - delete e; + tStopPlay* pEvent = new tStopPlay(0); + OutNow(pEvent); + delete pEvent; } AllNotesOff(); RecdBuffer.Keyoff2Length(); @@ -795,11 +801,11 @@ midi_event *m = state->recd_buffer.get(); // Event? - JZEvent *e = Dword2Event(m->data); - if (e) + JZEvent* pEvent = Dword2Event(m->data); + if (pEvent) { - e->SetClock(PlayLoop->Ext2IntClock(Time2RealTimeClock(m->ref))); - RecdBuffer.Put(e); + pEvent->SetClock(PlayLoop->Ext2IntClock(Time2RealTimeClock(m->ref))); + RecdBuffer.Put(pEvent); } } @@ -811,19 +817,19 @@ if ( !OutOfBandEvents.IsEmpty() ) { tEventIterator Iterator(&OutOfBandEvents); - JZEvent *e = Iterator.Range(0, clock); - while (e) + JZEvent* pEvent = Iterator.Range(0, clock); + while (pEvent) { - switch (e->Stat) + switch (pEvent->GetStat()) { case StatSetTempo: - SetRealTimeTempo( ((tSetTempo *)e)->GetBPM(), clock ); + SetRealTimeTempo( ((tSetTempo *)pEvent)->GetBPM(), clock ); break; default: break; } - e->Kill(); - e = Iterator.Next(); + pEvent->Kill(); + pEvent = Iterator.Next(); } OutOfBandEvents.Cleanup(0); } @@ -863,11 +869,11 @@ } // Event? - JZEvent *e = Dword2Event(m->data); - if (e) + JZEvent* pEvent = Dword2Event(m->data); + if (pEvent) { - e->SetClock(PlayLoop->Ext2IntClock(m->ref)); - RecdBuffer.Put(e); + pEvent->SetClock(PlayLoop->Ext2IntClock(m->ref)); + RecdBuffer.Put(pEvent); } } @@ -908,11 +914,11 @@ } // Event? - JZEvent *e = Dword2Event(m->data); - if (e) + JZEvent* pEvent = Dword2Event(m->data); + if (pEvent) { - e->SetClock(PlayLoop->Ext2IntClock(Time2Clock(m->ref))); - RecdBuffer.Put(e); + pEvent->SetClock(PlayLoop->Ext2IntClock(Time2Clock(m->ref))); + RecdBuffer.Put(pEvent); } } @@ -949,19 +955,19 @@ if ( !OutOfBandEvents.IsEmpty() ) { tEventIterator Iterator(&OutOfBandEvents); - JZEvent *e = Iterator.Range(0, clock); - while (e) + JZEvent* pEvent = Iterator.Range(0, clock); + while (pEvent) { - switch (e->Stat) + switch (pEvent->GetStat()) { case StatSetTempo: - SetRealTimeTempo( ((tSetTempo *)e)->GetBPM(), clock ); + SetRealTimeTempo( ((tSetTempo *)pEvent)->GetBPM(), clock ); break; default: break; } - e->Kill(); - e = Iterator.Next(); + pEvent->Kill(); + pEvent = Iterator.Next(); } OutOfBandEvents.Cleanup(0); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-19 05:56:51
|
Revision: 546 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=546&view=rev Author: pstieber Date: 2008-05-18 22:56:49 -0700 (Sun, 18 May 2008) Log Message: ----------- Made all members of the key on event private and added the appropriate accessors. Modified Paths: -------------- trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/Audio.cpp trunk/jazz/src/Command.cpp trunk/jazz/src/ControlEdit.cpp trunk/jazz/src/Dialogs/KeyOnDialog.cpp trunk/jazz/src/Dialogs/KeyOnDialog.h trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Events.h trunk/jazz/src/Harmony.cpp trunk/jazz/src/HarmonyBrowserAnalyzer.cpp trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/Player.cpp trunk/jazz/src/Rhythm.cpp trunk/jazz/src/Song.cpp trunk/jazz/src/Track.cpp trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -411,22 +411,22 @@ { case StatKeyOn: { - tKeyOn *k = pEvent->IsKeyOn(); + tKeyOn* pKeyOn = pEvent->IsKeyOn(); set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_NOTEON); - ev.data.note.channel = k->Channel; - ev.data.note.note = k->mKey; - ev.data.note.velocity = k->mVelocity; + ev.data.note.channel = pKeyOn->Channel; + ev.data.note.note = pKeyOn->GetKey(); + ev.data.note.velocity = pKeyOn->GetVelocity(); rc = write(&ev, now); } break; case StatKeyOff: { - tKeyOff *k = pEvent->IsKeyOff(); + tKeyOff* pKeyOff = pEvent->IsKeyOff(); set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_NOTEOFF); - ev.data.note.channel = k->Channel; - ev.data.note.note = k->Key; - ev.data.note.velocity = k->OffVeloc; + ev.data.note.channel = pKeyOff->Channel; + ev.data.note.note = pKeyOff->Key; + ev.data.note.velocity = pKeyOff->OffVeloc; rc = write(&ev, now); } break; Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Audio.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -466,7 +466,7 @@ tKeyOn* pKeyOn = e->IsKeyOn(); if (pKeyOn && num_voices < MAXPOLY) { - voices[num_voices++]->Start(samples[pKeyOn->mKey], pKeyOn->GetClock()); + voices[num_voices++]->Start(samples[pKeyOn->GetKey()], pKeyOn->GetClock()); } } @@ -582,11 +582,13 @@ tKeyOn* pKeyOn = e->IsKeyOn(); if (pKeyOn) { - pKeyOn->mLength = - (int)Samples2Ticks(samples[pKeyOn->mKey]->GetLength()); - if (pKeyOn->mLength < 15) // invisble? + pKeyOn->SetLength( + (int)Samples2Ticks(samples[pKeyOn->GetKey()]->GetLength())); + + // Is the event visble? + if (pKeyOn->GetEventLength() < 15) { - pKeyOn->mLength = 15; + pKeyOn->SetLength(15); } } e = it.Next(); Modified: trunk/jazz/src/Command.cpp =================================================================== --- trunk/jazz/src/Command.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Command.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -140,7 +140,7 @@ tKeyOn* pKeyOn = pEvent->IsKeyOn(); if (pKeyOn) { - Keys[pKeyOn->mKey] += pKeyOn->mLength; + Keys[pKeyOn->GetKey()] += pKeyOn->GetEventLength(); } } @@ -371,7 +371,7 @@ } if (NoteLength) { - pKeyOn->mLength = Quantize(pKeyOn->mLength, 2); + pKeyOn->SetLength(Quantize(pKeyOn->GetEventLength(), 2)); } pTrack->Kill(pEvent); pTrack->Put(pKeyOn); @@ -398,12 +398,12 @@ pKeyOn = (tKeyOn *)pEvent->Copy(); if (FitIntoScale) { - pKeyOn->mKey += Notes; - pKeyOn->mKey = Scale.FitInto(pKeyOn->mKey); + pKeyOn->SetKey(pKeyOn->GetKey() + Notes); + pKeyOn->SetKey(Scale.FitInto(pKeyOn->GetKey())); } else if (Notes) { - pKeyOn->mKey = Scale.Transpose(pKeyOn->mKey, Notes); + pKeyOn->SetKey(Scale.Transpose(pKeyOn->GetKey(), Notes)); } pTrack->Kill(pEvent); pTrack->Put(pKeyOn); @@ -478,13 +478,13 @@ case 0: break; case 1: - val = pKeyOn->mVelocity + val; + val = pKeyOn->GetVelocity() + val; break; case 2: - val = pKeyOn->mVelocity - val; + val = pKeyOn->GetVelocity() - val; break; } - pKeyOn->mVelocity = val < 1 ? 1 : (val > 127 ? 127 : val); + pKeyOn->SetVelocity(val < 1 ? 1 : (val > 127 ? 127 : val)); pTrack->Kill(pEvent); pTrack->Put(pKeyOn); } @@ -519,14 +519,14 @@ case 0: break; case 1: - val = pKeyOn->mLength + val; + val = pKeyOn->GetEventLength() + val; break; case 2: - val = pKeyOn->mLength - val; + val = pKeyOn->GetEventLength() - val; break; } - pKeyOn->mLength = val < 1 ? 1 : val; + pKeyOn->SetLength(val < 1 ? 1 : val); pTrack->Kill(pEvent); pTrack->Put(pKeyOn); } @@ -619,9 +619,9 @@ if (startclock == -1) { startclock = pEvent->IsKeyOn()->GetClock(); - startvelocity = pEvent->IsKeyOn()->mVelocity; + startvelocity = pEvent->IsKeyOn()->GetVelocity(); channel = pEvent->IsKeyOn()->Channel; - startkey = pEvent->IsKeyOn()->mKey; + startkey = pEvent->IsKeyOn()->GetKey(); previouspitch = pEvent->GetPitch(); } pitchdiff = pEvent->GetPitch()-previouspitch; @@ -636,10 +636,18 @@ pTrack->Kill(pEvent); //remove the old event - pTrack->Put(new tControl(pEvent->GetClock(), channel, 0x07, pEvent->IsKeyOn()->mVelocity)); - pTrack->Put(new tControl(pEvent->GetClock() + pEvent->IsKeyOn()->mLength, channel, 0x07, 0)); + pTrack->Put(new tControl( + pEvent->GetClock(), + channel, + 0x07, + pEvent->IsKeyOn()->GetVelocity())); + pTrack->Put(new tControl( + pEvent->GetClock() + pEvent->IsKeyOn()->GetEventLength(), + channel, + 0x07, + 0)); - lastlength = pEvent->IsKeyOn()->mLength; + lastlength = pEvent->IsKeyOn()->GetEventLength(); endclock = pEvent->GetClock(); previouspitch = pEvent->GetPitch(); } @@ -685,7 +693,8 @@ // only echo note events pKeyOn = (tKeyOn *)pEvent->Copy(); pKeyOn->SetClock(pKeyOn->GetClock()+ clockDelay * i); - pKeyOn->mVelocity = (unsigned char)(pow(scale, i) * pKeyOn->mVelocity); + pKeyOn->SetVelocity( + (unsigned char)(pow(scale, i) * pKeyOn->GetVelocity())); pTrack->Put(pKeyOn); } } @@ -715,24 +724,28 @@ tKeyOn* pKeyOn; if ((pKeyOn = pEvent->IsKeyOn()) != 0) { - if (pKeyOn->mLength < lengthLimit) + if (pKeyOn->GetEventLength() < lengthLimit) { - // remove short notes + // Remove short notes. pTrack->Kill(pEvent); } else if (shortenOverlaps) { - // shorten length of overlapping notes - tKeyOn *p = prev_note[pKeyOn->Channel][pKeyOn->mKey]; - if (p && p->GetClock() + p->mLength >= pKeyOn->GetClock()) + // Shorten length of overlapping notes. + tKeyOn* pPreviousKeyOn = prev_note[pKeyOn->Channel][pKeyOn->GetKey()]; + if ( + pPreviousKeyOn && + pPreviousKeyOn->GetClock() + pPreviousKeyOn->GetEventLength() >= + pKeyOn->GetClock()) { - p->mLength = pKeyOn->GetClock() - p->GetClock() - 1; - if (p->mLength < lengthLimit) + pPreviousKeyOn->SetLength( + pKeyOn->GetClock() - pPreviousKeyOn->GetClock() - 1); + if (pPreviousKeyOn->GetEventLength() < lengthLimit) { - pTrack->Kill(p); + pTrack->Kill(pPreviousKeyOn); } } - prev_note[pKeyOn->Channel][pKeyOn->mKey] = pKeyOn; + prev_note[pKeyOn->Channel][pKeyOn->GetKey()] = pKeyOn; } } } @@ -976,7 +989,7 @@ if (mpFilter->IsSelected(pEvent) && pEvent->IsKeyOn()) { tKeyOn* pKeyOn = (tKeyOn *)pEvent; - Keys[pKeyOn->mKey] = 1; + Keys[pKeyOn->GetKey()] = 1; } pEvent = Iterator.Next(); } @@ -992,7 +1005,7 @@ int n_th = 0; // the n'th key from bottom .. - for (i = 0; i <= pKeyOn->mKey; i++) + for (i = 0; i <= pKeyOn->GetKey(); i++) { n_th += Keys[i]; } @@ -1003,7 +1016,7 @@ n_th -= Keys[i]; } - pKeyOn->mKey = i + 1; + pKeyOn->SetKey(i + 1); pTrack->Kill(pEvent); pTrack->Put(pKeyOn); @@ -1056,15 +1069,15 @@ switch (mSource) { case veloc: - sval = mRandomArray[(int)pKeyOn->mVelocity]; + sval = mRandomArray[(int)pKeyOn->GetVelocity()]; break; case length: - sval = mRandomArray[(int)pKeyOn->mLength]; + sval = mRandomArray[(int)pKeyOn->GetEventLength()]; break; case key: - sval = mRandomArray[(int)pKeyOn->mKey]; + sval = mRandomArray[(int)pKeyOn->GetKey()]; break; case rhythm: @@ -1106,7 +1119,7 @@ { if (mAdd) { - sval = pKeyOn->mVelocity + sval; + sval = pKeyOn->GetVelocity() + sval; } if (sval > 127) { @@ -1118,7 +1131,7 @@ } tKeyOn* pKeyOnCopy = (tKeyOn *)pKeyOn->Copy(); pTrack->Kill(pKeyOn); - pKeyOnCopy->mVelocity = sval; + pKeyOnCopy->SetVelocity(sval); pTrack->Put(pKeyOnCopy); } break; @@ -1127,7 +1140,7 @@ { if (mAdd) { - sval = pKeyOn->mKey + sval; + sval = pKeyOn->GetKey() + sval; } if (sval > 127) { @@ -1139,7 +1152,7 @@ } tKeyOn* pKeyOnCopy = (tKeyOn *)pKeyOn->Copy(); pTrack->Kill(pKeyOn); - pKeyOnCopy->mKey = sval; + pKeyOnCopy->SetKey(sval); pTrack->Put(pKeyOnCopy); } break; @@ -1148,7 +1161,7 @@ { if (mAdd) { - sval = pKeyOn->mLength + sval; + sval = pKeyOn->GetEventLength() + sval; } if (sval < 1) { @@ -1156,7 +1169,7 @@ } tKeyOn* pKeyOnCopy = (tKeyOn *)pKeyOn->Copy(); pTrack->Kill(pKeyOn); - pKeyOnCopy->mLength = sval; + pKeyOnCopy->SetLength(sval); pTrack->Put(pKeyOnCopy); } break; Modified: trunk/jazz/src/ControlEdit.cpp =================================================================== --- trunk/jazz/src/ControlEdit.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/ControlEdit.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -528,7 +528,7 @@ int tVelocEdit::GetValue(JZEvent* pEvent) { - return pEvent->IsKeyOn()->mVelocity; + return pEvent->IsKeyOn()->GetVelocity(); } void tVelocEdit::OnApply() @@ -568,7 +568,7 @@ tKeyOn* pKeyOnCopy = pKeyOn->Copy()->IsKeyOn(); int i = Clock2i(pKeyOnCopy->GetClock()); - pKeyOnCopy->mVelocity = array[i]; + pKeyOnCopy->SetVelocity(array[i]); track->Kill(pKeyOn); track->Put(pKeyOnCopy); } @@ -665,7 +665,7 @@ to_clk = to_clock; } tKeyPressure *k; - tKeyOn *keyon; + tKeyOn* pKeyOn; if (!ctrlmode) { @@ -699,13 +699,13 @@ !mpPianoWindow->mpSnapSel->IsSelected() || mpPianoWindow->GetFilter()->IsSelected(pEvent)) { - keyon = pEvent->IsKeyOn(); - if (keyon) + pKeyOn = pEvent->IsKeyOn(); + if (pKeyOn) { - key_clk = keyon->GetClock() + 1; - key_end = keyon->GetClock() + keyon->mLength; - key_val = keyon->mKey; - key_cha = keyon->Channel; + key_clk = pKeyOn->GetClock() + 1; + key_end = pKeyOn->GetClock() + pKeyOn->GetEventLength(); + key_val = pKeyOn->GetKey(); + key_cha = pKeyOn->Channel; } if (key_val>0) { Modified: trunk/jazz/src/Dialogs/KeyOnDialog.cpp =================================================================== --- trunk/jazz/src/Dialogs/KeyOnDialog.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Dialogs/KeyOnDialog.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -178,15 +178,15 @@ bool JZKeyOnDialog::TransferDataToWindow() { string KeyString; - KeyToString(mpEvent->mKey, KeyString); + KeyToString(mpEvent->GetKey(), KeyString); mpPitchEdit->ChangeValue(KeyString.c_str()); ostringstream Oss; - Oss << (int)mpEvent->mVelocity; + Oss << (int)mpEvent->GetVelocity(); mpVelocityValue->SetLabel(Oss.str().c_str()); - mpVelocityKnob->SetValue(mpEvent->mVelocity); + mpVelocityKnob->SetValue(mpEvent->GetVelocity()); Oss.str(""); Oss << (int)mpEvent->GetOffVelocity(); @@ -195,7 +195,7 @@ mpOffVelocityKnob->SetValue(mpEvent->GetOffVelocity()); wxString LengthString; - LengthString << mpEvent->mLength; + LengthString << mpEvent->GetEventLength(); mpLengthEdit->ChangeValue(LengthString); Oss.str(""); @@ -216,15 +216,17 @@ bool JZKeyOnDialog::TransferDataFromWindow() { wxString KeyString = mpPitchEdit->GetValue(); - mpEvent->mKey = StringToKey(KeyString.c_str()); + mpEvent->SetKey(StringToKey(KeyString.c_str())); - mpEvent->mVelocity = mpVelocityKnob->GetValue(); + mpEvent->SetVelocity(mpVelocityKnob->GetValue()); mpEvent->SetOffVelocity(mpOffVelocityKnob->GetValue()); wxString LengthString = mpLengthEdit->GetValue(); istringstream Iss(LengthString.c_str()); - Iss >> mpEvent->mLength; + unsigned short Length; + Iss >> Length; + mpEvent->SetLength(Length); mpEvent->Channel = mpChannelKnob->GetValue() - 1; Modified: trunk/jazz/src/Dialogs/KeyOnDialog.h =================================================================== --- trunk/jazz/src/Dialogs/KeyOnDialog.h 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Dialogs/KeyOnDialog.h 2008-05-19 05:56:49 UTC (rev 546) @@ -50,10 +50,6 @@ private: tKeyOn* mpEvent; -// int mPitch; -// int mVelocity; -// int mLength; -// int mOffVelocity; wxTextCtrl* mpPitchEdit; wxStaticText* mpVelocityValue; Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Dialogs.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -1367,7 +1367,9 @@ if (t->GetAudioMode()) { if (!gpMidiPlayer->IsPlaying()) - gpMidiPlayer->EditSample(e->IsKeyOn()->mKey); + { + gpMidiPlayer->EditSample(e->IsKeyOn()->GetKey()); + } break; } str = "Key On"; Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Events.h 2008-05-19 05:56:49 UTC (rev 546) @@ -550,28 +550,16 @@ { public: - unsigned char mKey; - unsigned char mVelocity; - - // Length is 0 if a corresponding tKeyOff exists. - unsigned short mLength; - - private: - - unsigned short mOffVelocity; - - public: - tKeyOn( int clk, int cha, unsigned char Key, unsigned char Velocity, - unsigned short len = 0) + unsigned short Length = 0) : tChannelEvent(clk, StatKeyOn, cha), mKey(Key), mVelocity(Velocity), - mLength(len), + mLength(Length), mOffVelocity(0) { } @@ -594,36 +582,61 @@ return new tKeyOn(*this); } - virtual unsigned short GetEventLength() const + virtual int GetValue() const { edb(); - return mLength; + return mKey; } - virtual int GetLength() const + virtual int GetPitch() const { edb(); - return mLength; + return mKey; } - virtual int GetValue() const + virtual void SetPitch(int p) { edb(); + mKey = p; + } + + unsigned char GetKey() const + { return mKey; } - virtual int GetPitch() const + void SetKey(unsigned char Key) { + mKey = Key; + } + + unsigned char GetVelocity() const + { + return mVelocity; + } + + void SetVelocity(unsigned char Velocity) + { + mVelocity = Velocity; + } + + virtual unsigned short GetEventLength() const + { edb(); - return mKey; + return mLength; } - virtual void SetPitch(int p) + virtual int GetLength() const { edb(); - mKey = p; + return mLength; } + void SetLength(unsigned short Length) + { + mLength = Length; + } + unsigned short GetOffVelocity() const { return mOffVelocity; @@ -643,6 +656,17 @@ { return wxBLACK_BRUSH; } + + private: + + unsigned char mKey; + + unsigned char mVelocity; + + // Length is 0 if a corresponding tKeyOff exists. + unsigned short mLength; + + unsigned short mOffVelocity; }; Modified: trunk/jazz/src/Harmony.cpp =================================================================== --- trunk/jazz/src/Harmony.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Harmony.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -711,7 +711,7 @@ tKeyOn* pKeyOn = buf.Events[i]->IsKeyOn(); if (pKeyOn) { - piano += pKeyOn->mKey; + piano += pKeyOn->GetKey(); } } } Modified: trunk/jazz/src/HarmonyBrowserAnalyzer.cpp =================================================================== --- trunk/jazz/src/HarmonyBrowserAnalyzer.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/HarmonyBrowserAnalyzer.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -167,18 +167,18 @@ int start = Step2Clock(i); int stop = Step2Clock(i+1); if ( - pKeyOn->GetClock() + pKeyOn->mLength >= start && + pKeyOn->GetClock() + pKeyOn->GetEventLength() >= start && pKeyOn->GetClock() < stop) { if (pKeyOn->GetClock() > start) { start = pKeyOn->GetClock(); } - if (pKeyOn->GetClock() + pKeyOn->mLength < stop) + if (pKeyOn->GetClock() + pKeyOn->GetEventLength() < stop) { - stop = pKeyOn->GetClock() + pKeyOn->mLength; + stop = pKeyOn->GetClock() + pKeyOn->GetEventLength(); } - count[i][pKeyOn->mKey % 12] += stop - start; + count[i][pKeyOn->GetKey() % 12] += stop - start; } } } @@ -191,7 +191,7 @@ int start = Step2Clock(i); int stop = Step2Clock(i+1); if ( - pKeyOn->GetClock() + pKeyOn->mLength >= start && + pKeyOn->GetClock() + pKeyOn->GetEventLength() >= start && pKeyOn->GetClock() < stop) { // key matches this step @@ -201,17 +201,17 @@ { fr = pKeyOn->GetClock(); } - if (pKeyOn->GetClock() + pKeyOn->mLength < to) + if (pKeyOn->GetClock() + pKeyOn->GetEventLength() < to) { - to = pKeyOn->GetClock() + pKeyOn->mLength; + to = pKeyOn->GetClock() + pKeyOn->GetEventLength(); } // transpose if most of key length belongs to this step // OR: it covers the whole step - if (to - fr >= pKeyOn->mLength / 2 || (fr == start && to == stop)) + if (to - fr >= pKeyOn->GetEventLength() / 2 || (fr == start && to == stop)) { tKeyOn* pKeyOnCopy = (tKeyOn *)pKeyOn->Copy(); - pKeyOnCopy->mKey += delta[i][pKeyOn->mKey % 12]; + pKeyOnCopy->SetKey(pKeyOnCopy->GetKey() + delta[i][pKeyOn->GetKey() % 12]); pTrack->Kill(pKeyOn); pTrack->Put(pKeyOnCopy); Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/PianoWindow.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -266,7 +266,7 @@ { Length = 1; } - Copy->mLength = Length; + Copy->SetLength(Length); Win->DrawEvent(Dc, Copy, Copy->GetBrush(), 1, 1); return 0; @@ -277,16 +277,16 @@ int tKeyLengthDragger::ButtonUp(wxMouseEvent& Event) { // SN++ Key_Aftertouch - if (Copy->mLength < mpKeyOn->mLength) + if (Copy->GetEventLength() < mpKeyOn->GetEventLength()) { int key, channel; tEventIterator iter(Win->GetTrack()); tKeyPressure *a; - key = Copy->mKey; + key = Copy->GetKey(); channel = Copy->Channel; JZEvent* pEvent = iter.Range( - Copy->GetClock() + Copy->mLength, - Copy->GetClock() + mpKeyOn->mLength); + Copy->GetClock() + Copy->GetEventLength(), + Copy->GetClock() + mpKeyOn->GetEventLength()); while (pEvent) { a = pEvent->IsKeyPressure(); @@ -421,7 +421,7 @@ JZPianoWindow* pPianoWindow, JZRectangle* pRectangle, tKeyOn* pKeyOn) - : tMouseCounter(pPianoWindow, pRectangle, pKeyOn->mVelocity, 1, 127) + : tMouseCounter(pPianoWindow, pRectangle, pKeyOn->GetVelocity(), 1, 127) { Win = pPianoWindow; mpKeyOn = pKeyOn; @@ -447,7 +447,7 @@ if (tMouseCounter::Event(Event)) { tKeyOn* pKeyOnCopy = (tKeyOn *)mpKeyOn->Copy(); - pKeyOnCopy->mVelocity = Value; + pKeyOnCopy->SetVelocity(Value); Win->ApplyToTrack(mpKeyOn, pKeyOnCopy); @@ -1376,7 +1376,7 @@ // show velocity as colors if (force_color != 0 && mUseColors && pEvent->IsKeyOn()) { - int vel = pEvent->IsKeyOn()->mVelocity; + int vel = pEvent->IsKeyOn()->GetVelocity(); // Next line is "Patrick Approved." Dc.SetBrush(mpColorBrush[ vel * NUM_COLORS / 128 ]); @@ -1458,7 +1458,7 @@ // show velocity as colors if (!force_color && mUseColors && pEvent->IsKeyOn()) { - int vel = pEvent->IsKeyOn()->mVelocity; + int vel = pEvent->IsKeyOn()->GetVelocity(); Dc.SetBrush(mpColorBrush[ vel * NUM_COLORS / 128 ]); } else @@ -2410,13 +2410,15 @@ { return; } - if (pKeyOn->mLength < 2) + if (pKeyOn->GetEventLength() < 2) { return; } - key = pKeyOn->mKey; + key = pKeyOn->GetKey(); channel = pKeyOn->Channel; - pEvent = iter.Range(pKeyOn->GetClock() + 1, pKeyOn->GetClock() + pKeyOn->mLength); + pEvent = iter.Range( + pKeyOn->GetClock() + 1, + pKeyOn->GetClock() + pKeyOn->GetEventLength()); while (pEvent) { a = pEvent->IsKeyPressure(); @@ -2444,15 +2446,15 @@ return; } channel = pKeyOn->Channel; - if (pKeyOn->mLength < 2) + if (pKeyOn->GetEventLength() < 2) { return; } - key = pKeyOn->mKey; + key = pKeyOn->GetKey(); pEvent = iter.Range( pKeyOn->GetClock() + 1, - pKeyOn->GetClock() + pKeyOn->mLength); + pKeyOn->GetClock() + pKeyOn->GetEventLength()); while (pEvent) { @@ -2951,16 +2953,16 @@ kill_keys_aftertouch(pTrack, pEvent); if (pTrack->GetAudioMode()) { - gpMidiPlayer->ListenAudio(pKeyOn->mKey, 0); + gpMidiPlayer->ListenAudio(pKeyOn->GetKey(), 0); } else { mListen.KeyOn( pTrack, - pKeyOn->mKey, + pKeyOn->GetKey(), pKeyOn->Channel, - pKeyOn->mVelocity, - pKeyOn->mLength); + pKeyOn->GetVelocity(), + pKeyOn->GetEventLength()); } } @@ -3045,16 +3047,16 @@ { if (pTrack->GetAudioMode()) { - gpMidiPlayer->ListenAudio(pKeyOn->mKey, 0); + gpMidiPlayer->ListenAudio(pKeyOn->GetKey(), 0); } else { mListen.KeyOn( pTrack, - pKeyOn->mKey, + pKeyOn->GetKey(), pKeyOn->Channel, - pKeyOn->mVelocity, - pKeyOn->mLength); + pKeyOn->GetVelocity(), + pKeyOn->GetEventLength()); } } wxClientDC Dc(this); Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Player.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -520,10 +520,10 @@ tKeyOn* pKeyOn = pEvent->IsKeyOn(); if (pKeyOn) { - if (pKeyOn->GetClock() + pKeyOn->mLength >= Clock - 100) + if (pKeyOn->GetClock() + pKeyOn->GetEventLength() >= Clock - 100) { off.Channel = pKeyOn->Channel; - off.Key = pKeyOn->mKey; + off.Key = pKeyOn->GetKey(); OutNow(&off); } } @@ -1631,8 +1631,8 @@ SEQ_START_NOTE( mididev, pKeyOn->Channel, - pKeyOn->mKey, - pKeyOn->mVelocity); + pKeyOn->GetKey(), + pKeyOn->GetVelocity()); if (now) seqbuf_flush_last_event(); } break; Modified: trunk/jazz/src/Rhythm.cpp =================================================================== --- trunk/jazz/src/Rhythm.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Rhythm.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -352,10 +352,10 @@ tEventArray &src = gpTrackWindow->GetPianoWindow()->PasteBuffer; for (int ii = 0; ii < src.nEvents; ii++) { - tKeyOn *on = src.Events[ii]->IsKeyOn(); - if (on) + tKeyOn* pKeyOn = src.Events[ii]->IsKeyOn(); + if (pKeyOn) { - tKeyOn *k = new tKeyOn(clock, chan, on->Key, vel, len - clocks_per_step/2); + tKeyOn *k = new tKeyOn(clock, chan, pKeyOn->Key, vel, len - clocks_per_step / 2); track->Put(k); } } @@ -938,16 +938,16 @@ for (int ii = 0; ii < events.nEvents; ii++) { - tKeyOn *on = events.Events[ii]->IsKeyOn(); - if (on) + tKeyOn* pKeyOn = events.Events[ii]->IsKeyOn(); + if (pKeyOn) { - pRhythm->keys[pRhythm->n_keys++] = on->mKey; + pRhythm->keys[pRhythm->n_keys++] = pKeyOn->GetKey(); if (pRhythm->n_keys > 1) { Oss << ", "; } string KeyString; - KeyToString(on->mKey, KeyString); + KeyToString(pKeyOn->GetKey(), KeyString); Oss << KeyString; if (pRhythm->n_keys >= MAX_KEYS) { Modified: trunk/jazz/src/Song.cpp =================================================================== --- trunk/jazz/src/Song.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Song.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -464,7 +464,7 @@ d->SetClock(d->GetClock() + c->GetClock() + loopOffset); if (d->IsKeyOn()) { - d->IsKeyOn()->mKey += c->transpose; + d->IsKeyOn()->SetKey(d->IsKeyOn()->GetKey() + c->transpose); } if (d->IsPlayTrack()) { @@ -571,7 +571,7 @@ tKeyOn* pKeyOn = pEvent->IsKeyOn(); if (pKeyOn) { - pKeyOn->mLength = (int)(f * pKeyOn->mLength + 0.5); + pKeyOn->SetLength((int)(f * pKeyOn->GetEventLength() + 0.5)); } } } Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/Track.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -1155,20 +1155,24 @@ int n = nEvents; for (int i = 0; i < n; i++) { - tKeyOn *on; - if ((on = Events[i]->IsKeyOn()) != 0 && on->mLength != 0) + tKeyOn* pKeyOn; + if ((pKeyOn = Events[i]->IsKeyOn()) != 0 && pKeyOn->GetEventLength() != 0) { -// JZEvent *of = new tKeyOff(on->GetClock() + on->mLength, on->Channel, on->Key); +// JZEvent* pKeyOff = new tKeyOff( +// pKeyOn->GetClock() + pKeyOn->GetEventLength(), +// pKeyOn->Channel, +// pKeyOn->Key); + // SN++ added off veloc - JZEvent *of = new tKeyOff( - on->GetClock() + on->mLength, - on->Channel, - on->mKey, - on->GetOffVelocity()); + JZEvent* pKeyOff = new tKeyOff( + pKeyOn->GetClock() + pKeyOn->GetEventLength(), + pKeyOn->Channel, + pKeyOn->GetKey(), + pKeyOn->GetOffVelocity()); - on->mLength = 0; - of->SetDevice(on->GetDevice()); - Put(of); + pKeyOn->SetLength(0); + pKeyOff->SetDevice(pKeyOn->GetDevice()); + Put(pKeyOff); } } Sort(); @@ -1182,21 +1186,25 @@ int i; for (i = 1; i < nEvents; i++) { - tKeyOff *of; - if ((of = Events[i]->IsKeyOff()) != 0) + tKeyOff* pKeyOff; + if ((pKeyOff = Events[i]->IsKeyOff()) != 0) { JZEvent **e = &Events[i - 1]; while (e >= Events) { - tKeyOn *on = (*e)->IsKeyOn(); - if (on && on->Key == of->Key && on->Channel == of->Channel && on->Length == 0) + tKeyOn* pKeyOn = (*e)->IsKeyOn(); + if ( + pKeyOn && + pKeyOn->Key == pKeyOff->Key && + pKeyOn->Channel == pKeyOff->Channel && + pKeyOn->Length == 0) { - on->Length = of->GetClock() - on->GetClock(); - if (on->Length <= 0L) + pKeyOn->Length = pKeyOff->GetClock() - pKeyOn->GetClock(); + if (pKeyOn->Length <= 0L) { - on->Length = 1; + pKeyOn->Length = 1; } - of->Kill(); + pKeyOff->Kill(); break; } --e; @@ -1225,25 +1233,25 @@ int i; for (i = 0; i < nEvents; i++) { - tKeyOn* on; - if ((on = Events[i]->IsKeyOn()) != 0 && on->mLength == 0) + tKeyOn* pKeyOn; + if ((pKeyOn = Events[i]->IsKeyOn()) != 0 && pKeyOn->GetEventLength() == 0) { int j; for (j = i + 1; j < nEvents; j++) { - tKeyOff *of = Events[j]->IsKeyOff(); + tKeyOff* pKeyOff = Events[j]->IsKeyOff(); if ( - of && - !of->IsKilled() && - on->mKey == of->Key && - on->Channel == of->Channel) + pKeyOff && + !pKeyOff->IsKilled() && + pKeyOn->GetKey() == pKeyOff->Key && + pKeyOn->Channel == pKeyOff->Channel) { - on->mLength = of->GetClock() - on->GetClock(); - if (on->mLength <= 0L) + pKeyOn->SetLength(pKeyOff->GetClock() - pKeyOn->GetClock()); + if (pKeyOn->GetEventLength() <= 0) { - on->mLength = 1; + pKeyOn->SetLength(1); } - of->Kill(); + pKeyOff->Kill(); break; } } @@ -1254,15 +1262,15 @@ // and kill all remaining KeyOff's for (i = 0; i < nEvents; i++) { - tKeyOn* on = Events[i]->IsKeyOn(); - if (on && on->mLength <= 0) + tKeyOn* pKeyOn = Events[i]->IsKeyOn(); + if (pKeyOn && pKeyOn->GetEventLength() <= 0) { - on->Kill(); + pKeyOn->Kill(); } - tKeyOff *of = Events[i]->IsKeyOff(); - if (of) + tKeyOff* pKeyOff = Events[i]->IsKeyOff(); + if (pKeyOff) { - of->Kill(); + pKeyOff->Kill(); } } Cleanup(0); Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-19 03:57:57 UTC (rev 545) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-19 05:56:49 UTC (rev 546) @@ -267,18 +267,18 @@ { case StatKeyOn: { - tKeyOn *k = pEvent->IsKeyOn(); - u.c[0] = 0x90 | k->Channel; - u.c[1] = k->mKey; - u.c[2] = k->mVelocity; + tKeyOn* pKeyOn = pEvent->IsKeyOn(); + u.c[0] = 0x90 | pKeyOn->Channel; + u.c[1] = pKeyOn->GetKey(); + u.c[2] = pKeyOn->GetVelocity(); } break; case StatKeyOff: { - tKeyOff *k = pEvent->IsKeyOff(); - u.c[0] = 0x80 | k->Channel; - u.c[1] = k->Key; + tKeyOff* pKeyOff = pEvent->IsKeyOff(); + u.c[0] = 0x80 | pKeyOff->Channel; + u.c[1] = pKeyOff->Key; u.c[2] = 0; } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-21 01:47:08
|
Revision: 549 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=549&view=rev Author: pstieber Date: 2008-05-20 18:47:00 -0700 (Tue, 20 May 2008) Log Message: ----------- Encapsulated the channel member. Modified Paths: -------------- trunk/jazz/src/AsciiMidiFile.cpp trunk/jazz/src/Command.cpp trunk/jazz/src/ControlEdit.cpp trunk/jazz/src/Dialogs/KeyOnDialog.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Events.cpp trunk/jazz/src/Events.h trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/Player.cpp trunk/jazz/src/StandardFile.cpp trunk/jazz/src/Track.cpp trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/AsciiMidiFile.cpp =================================================================== --- trunk/jazz/src/AsciiMidiFile.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/AsciiMidiFile.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -162,12 +162,12 @@ //----------------------------------------------------------------------------- int JZAsciiWrite::Write(JZEvent* pEvent, unsigned char* pData, int Length) { - tChannelEvent *ce; + tChannelEvent* pChannelEvent; fprintf(mpFd, "%6d %02x ", pEvent->GetClock(), pEvent->GetStat()); - if ((ce = pEvent->IsChannelEvent()) != 0) + if ((pChannelEvent = pEvent->IsChannelEvent()) != 0) { - fprintf(mpFd, "%2d ", ce->Channel); + fprintf(mpFd, "%2d ", pChannelEvent->GetChannel()); } else { Modified: trunk/jazz/src/Command.cpp =================================================================== --- trunk/jazz/src/Command.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/Command.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -443,7 +443,7 @@ if ((c = pEvent->IsChannelEvent()) != 0) { c = (tChannelEvent *)pEvent->Copy(); - c->Channel = NewChannel; + c->SetChannel(NewChannel); pTrack->Kill(pEvent); pTrack->Put(c); } @@ -620,7 +620,7 @@ { startclock = pEvent->IsKeyOn()->GetClock(); startvelocity = pEvent->IsKeyOn()->GetVelocity(); - channel = pEvent->IsKeyOn()->Channel; + channel = pEvent->IsKeyOn()->GetChannel(); startkey = pEvent->IsKeyOn()->GetKey(); previouspitch = pEvent->GetPitch(); } @@ -732,7 +732,7 @@ else if (shortenOverlaps) { // Shorten length of overlapping notes. - tKeyOn* pPreviousKeyOn = prev_note[pKeyOn->Channel][pKeyOn->GetKey()]; + tKeyOn* pPreviousKeyOn = prev_note[pKeyOn->GetChannel()][pKeyOn->GetKey()]; if ( pPreviousKeyOn && pPreviousKeyOn->GetClock() + pPreviousKeyOn->GetEventLength() >= @@ -745,7 +745,7 @@ pTrack->Kill(pPreviousKeyOn); } } - prev_note[pKeyOn->Channel][pKeyOn->GetKey()] = pKeyOn; + prev_note[pKeyOn->GetChannel()][pKeyOn->GetKey()] = pKeyOn; } } } Modified: trunk/jazz/src/ControlEdit.cpp =================================================================== --- trunk/jazz/src/ControlEdit.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/ControlEdit.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -705,7 +705,7 @@ key_clk = pKeyOn->GetClock() + 1; key_end = pKeyOn->GetClock() + pKeyOn->GetEventLength(); key_val = pKeyOn->GetKey(); - key_cha = pKeyOn->Channel; + key_cha = pKeyOn->GetChannel(); } if (key_val>0) { Modified: trunk/jazz/src/Dialogs/KeyOnDialog.cpp =================================================================== --- trunk/jazz/src/Dialogs/KeyOnDialog.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/Dialogs/KeyOnDialog.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -199,10 +199,10 @@ mpLengthEdit->ChangeValue(LengthString); Oss.str(""); - Oss << (int)mpEvent->Channel + 1; + Oss << (int)mpEvent->GetChannel() + 1; mpChannelValue->SetLabel(Oss.str().c_str()); - mpChannelKnob->SetValue(mpEvent->Channel + 1); + mpChannelKnob->SetValue(mpEvent->GetChannel() + 1); string ClockString; gpProject->ClockToString(mpEvent->GetClock(), ClockString); @@ -228,7 +228,7 @@ Iss >> Length; mpEvent->SetLength(Length); - mpEvent->Channel = mpChannelKnob->GetValue() - 1; + mpEvent->SetChannel(mpChannelKnob->GetValue() - 1); wxString ClockString = mpClockEdit->GetValue(); int Clock = gpProject->StringToClock(ClockString.c_str()); Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/Dialogs.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -763,10 +763,10 @@ int Channel; - tChEventDlg(tChannelEvent *e, JZPianoWindow* w, JZTrack *t) - : tEventDlg(e, w, t) + tChEventDlg(tChannelEvent* pChannelEvent, JZPianoWindow* w, JZTrack *t) + : tEventDlg(pChannelEvent, w, t) { - Channel = e->Channel + 1; // 1..16 + Channel = pChannelEvent->GetChannel() + 1; // 1..16 } void AddProperties(); bool OnClose(); @@ -785,7 +785,7 @@ bool tChEventDlg::OnClose() { - ((tChannelEvent *)Copy)->Channel = Channel - 1; + ((tChannelEvent *)Copy)->SetChannel(Channel - 1); tEventDlg::OnClose(); return false; } Modified: trunk/jazz/src/Events.cpp =================================================================== --- trunk/jazz/src/Events.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/Events.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -172,7 +172,7 @@ case StatPitch: nBytes = 0; - Buffer[nBytes++] = Stat | ((tChannelEvent *)pEvent)->Channel; + Buffer[nBytes++] = Stat | ((tChannelEvent *)pEvent)->GetChannel(); while(Length--) { Buffer[nBytes++] = *pData++; Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/Events.h 2008-05-21 01:47:00 UTC (rev 549) @@ -313,6 +313,10 @@ class tPlayTrack; class tEndOfTrack; +//***************************************************************************** +// Description: +// This is the MIDI event base class declaration. +//***************************************************************************** class JZEvent { public: @@ -521,12 +525,10 @@ { public: - unsigned char Channel; - - tChannelEvent(int clk, unsigned char sta, int cha) + tChannelEvent(int clk, unsigned char sta, int Channel) : JZEvent(clk, sta) { - Channel = cha; + mChannel = Channel; } virtual tChannelEvent* IsChannelEvent() @@ -540,6 +542,20 @@ edb(); return new tChannelEvent(*this); } + + unsigned char GetChannel() const + { + return mChannel; + } + + void SetChannel(unsigned char Channel) + { + mChannel = Channel; + } + + private: + + unsigned char mChannel; }; Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/PianoWindow.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -283,7 +283,7 @@ tEventIterator iter(Win->GetTrack()); tKeyPressure *a; key = Copy->GetKey(); - channel = Copy->Channel; + channel = Copy->GetChannel(); JZEvent* pEvent = iter.Range( Copy->GetClock() + Copy->GetEventLength(), Copy->GetClock() + mpKeyOn->GetEventLength()); @@ -292,7 +292,7 @@ a = pEvent->IsKeyPressure(); if (a) { - if (a->Key == key && a->Channel == channel) + if (a->Key == key && a->GetChannel() == channel) { Win->KillTrackEvent(pEvent); } @@ -2415,7 +2415,7 @@ return; } key = pKeyOn->GetKey(); - channel = pKeyOn->Channel; + channel = pKeyOn->GetChannel(); pEvent = iter.Range( pKeyOn->GetClock() + 1, pKeyOn->GetClock() + pKeyOn->GetEventLength()); @@ -2424,7 +2424,7 @@ a = pEvent->IsKeyPressure(); if (a) { - if (a->Key == key && a->Channel == channel) + if (a->Key == key && a->GetChannel() == channel) { pTrack->Kill(pEvent); } @@ -2445,7 +2445,7 @@ { return; } - channel = pKeyOn->Channel; + channel = pKeyOn->GetChannel(); if (pKeyOn->GetEventLength() < 2) { return; @@ -2461,7 +2461,7 @@ a = pEvent->IsKeyPressure(); if (a) { - if (a->Key == key && a->Channel == channel) + if (a->Key == key && a->GetChannel() == channel) { mPasteBuffer.Put(pEvent->Copy()); } @@ -2960,7 +2960,7 @@ mListen.KeyOn( pTrack, pKeyOn->GetKey(), - pKeyOn->Channel, + pKeyOn->GetChannel(), pKeyOn->GetVelocity(), pKeyOn->GetEventLength()); } @@ -3041,7 +3041,9 @@ c->SetPitch(c->GetPitch() + DeltaPitch); c->SetClock(c->GetClock() + DeltaClock); if (pTrack->ForceChannel && c->IsChannelEvent()) - c->IsChannelEvent()->Channel = pTrack->Channel - 1; + { + c->IsChannelEvent()->SetChannel(pTrack->Channel - 1); + } tKeyOn* pKeyOn = c->IsKeyOn(); if (pKeyOn) { @@ -3054,7 +3056,7 @@ mListen.KeyOn( pTrack, pKeyOn->GetKey(), - pKeyOn->Channel, + pKeyOn->GetChannel(), pKeyOn->GetVelocity(), pKeyOn->GetEventLength()); } Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/Player.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -522,7 +522,7 @@ { if (pKeyOn->GetClock() + pKeyOn->GetEventLength() >= Clock - 100) { - off.Channel = pKeyOn->Channel; + off.SetChannel(pKeyOn->GetChannel()); off.Key = pKeyOn->GetKey(); OutNow(&off); } @@ -622,15 +622,15 @@ { for (int c = 0; c < 16; c++) { - NoteOff.Channel = c; + NoteOff.SetChannel(c); NoteOff.SetDevice(dev); OutNow(&NoteOff); - Pitch.Channel = c; + Pitch.SetChannel(c); Pitch.SetDevice(dev); OutNow(&Pitch); - CtrlRes.Channel = c; + CtrlRes.SetChannel(c); CtrlRes.SetDevice(dev); OutNow(&CtrlRes); } Modified: trunk/jazz/src/StandardFile.cpp =================================================================== --- trunk/jazz/src/StandardFile.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/StandardFile.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -249,7 +249,7 @@ // SN-- only if KeyOff veloc is zero if (!pEvent->IsKeyOff()->OffVeloc) { - Stat = StatKeyOn | pEvent->IsChannelEvent()->Channel; + Stat = StatKeyOn | pEvent->IsChannelEvent()->GetChannel(); if (Stat != RunningStatus) { RunningStatus = Stat; @@ -260,7 +260,7 @@ } else { - Stat = StatKeyOff | pEvent->IsChannelEvent()->Channel; + Stat = StatKeyOff | pEvent->IsChannelEvent()->GetChannel(); if (Stat != RunningStatus) { RunningStatus = Stat; @@ -281,7 +281,7 @@ // SN++ case StatChnPressure: - Stat = pEvent->GetStat() | pEvent->IsChannelEvent()->Channel; + Stat = pEvent->GetStat() | pEvent->IsChannelEvent()->GetChannel(); if (Stat != RunningStatus) { RunningStatus = Stat; Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/Track.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -40,17 +40,17 @@ return mMsb.Write(Io) + mLsb.Write(Io) + mDataMsb.Write(Io); } -void tParam::SetCha(unsigned char cha) +void tParam::SetCha(unsigned char Channel) { - mMsb.Channel = cha; - mLsb.Channel = cha; - mDataMsb.Channel = cha; + mMsb.SetChannel(Channel); + mLsb.SetChannel(Channel); + mDataMsb.SetChannel(Channel); #ifdef OBSOLETE - mResetMb.Channel = cha; //???? JAVE commented out this while porting + mResetMb.SetChannel(Channel); //???? JAVE commented out this while porting #endif // OBSOLETE - mResetLsb.Channel = cha; + mResetLsb.SetChannel(Channel); } /* @@ -1166,7 +1166,7 @@ // SN++ added off veloc JZEvent* pKeyOff = new tKeyOff( pKeyOn->GetClock() + pKeyOn->GetEventLength(), - pKeyOn->Channel, + pKeyOn->GetChannel(), pKeyOn->GetKey(), pKeyOn->GetOffVelocity()); @@ -1244,7 +1244,7 @@ pKeyOff && !pKeyOff->IsKilled() && pKeyOn->GetKey() == pKeyOff->Key && - pKeyOn->Channel == pKeyOff->Channel) + pKeyOn->GetChannel() == pKeyOff->GetChannel()) { pKeyOn->SetLength(pKeyOff->GetClock() - pKeyOn->GetClock()); if (pKeyOn->GetEventLength() <= 0) @@ -1476,7 +1476,7 @@ case 0x06: Data = e->IsControl()->mValue; // Rpn/Nrpn Data SpecialEvent = 1; - cha = e->IsControl()->Channel; + cha = e->IsControl()->GetChannel(); switch (Msb) { case 0x01: // Nrpn @@ -1630,7 +1630,7 @@ NeedToDelete = false; if (!Channel && e->IsChannelEvent()) { - Channel = e->IsChannelEvent()->Channel + 1; + Channel = e->IsChannelEvent()->GetChannel() + 1; } } if (e->IsEndOfTrack()) @@ -1767,7 +1767,7 @@ if ((c = e->IsChannelEvent()) != 0) { c = (tChannelEvent *)e->Copy(); - c->Channel = trk->Channel - 1; + c->SetChannel(trk->Channel - 1); trk->Kill(e); trk->Put(c); } @@ -2002,10 +2002,10 @@ JZEvent *c = e->Copy(); if (ForceChannel) { - tChannelEvent *k = c->IsChannelEvent(); - if (k) + tChannelEvent* pChannelEvent = c->IsChannelEvent(); + if (pChannelEvent) { - k->Channel = Channel - 1; + pChannelEvent->SetChannel(Channel - 1); } } Put(c); Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-20 04:43:07 UTC (rev 548) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-21 01:47:00 UTC (rev 549) @@ -268,7 +268,7 @@ case StatKeyOn: { tKeyOn* pKeyOn = pEvent->IsKeyOn(); - u.c[0] = 0x90 | pKeyOn->Channel; + u.c[0] = 0x90 | pKeyOn->GetChannel(); u.c[1] = pKeyOn->GetKey(); u.c[2] = pKeyOn->GetVelocity(); } @@ -277,7 +277,7 @@ case StatKeyOff: { tKeyOff* pKeyOff = pEvent->IsKeyOff(); - u.c[0] = 0x80 | pKeyOff->Channel; + u.c[0] = 0x80 | pKeyOff->GetChannel(); u.c[1] = pKeyOff->Key; u.c[2] = 0; } @@ -286,7 +286,7 @@ case StatProgram: { tProgram *k = pEvent->IsProgram(); - u.c[0] = 0xC0 | k->Channel; + u.c[0] = 0xC0 | k->GetChannel(); u.c[1] = k->Program; } break; @@ -294,7 +294,7 @@ case StatChnPressure: { tChnPressure *k = pEvent->IsChnPressure(); - u.c[0] = 0xC0 | k->Channel; + u.c[0] = 0xC0 | k->GetChannel(); u.c[1] = k->Value; } break; @@ -302,7 +302,7 @@ case StatControl: { tControl* pControl = pEvent->IsControl(); - u.c[0] = 0xB0 | pControl->Channel; + u.c[0] = 0xB0 | pControl->GetChannel(); u.c[1] = pControl->mControl; u.c[2] = pControl->mValue; } @@ -311,7 +311,7 @@ case StatKeyPressure: { tKeyPressure *k = pEvent->IsKeyPressure(); - u.c[0] = 0xA0 | k->Channel; + u.c[0] = 0xA0 | k->GetChannel(); u.c[1] = k->Key; u.c[2] = k->Value; } @@ -321,7 +321,7 @@ { tPitch *k = pEvent->IsPitch(); int v = k->Value + 8192; - u.c[0] = 0xE0 | k->Channel; + u.c[0] = 0xE0 | k->GetChannel(); u.c[1] = (unsigned char)(v & 0x7F); u.c[2] = (unsigned char)(v >> 7); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-22 05:26:27
|
Revision: 552 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=552&view=rev Author: pstieber Date: 2008-05-21 22:26:26 -0700 (Wed, 21 May 2008) Log Message: ----------- Started using accessors in the tProgram event class. Modified Paths: -------------- trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Events.h trunk/jazz/src/Player.cpp trunk/jazz/src/Track.cpp trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-05-21 15:51:25 UTC (rev 551) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-05-22 05:26:26 UTC (rev 552) @@ -433,10 +433,10 @@ case StatProgram: { - tProgram *k = pEvent->IsProgram(); + tProgram* pProgram = pEvent->IsProgram(); set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_PGMCHANGE); - ev.data.control.channel = k->GetChannel(); - ev.data.control.value = k->Program; + ev.data.control.channel = pProgram->GetChannel(); + ev.data.control.value = pProgram->GetProgram(); rc = write(&ev, now); } break; Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2008-05-21 15:51:25 UTC (rev 551) +++ trunk/jazz/src/Dialogs.cpp 2008-05-22 05:26:26 UTC (rev 552) @@ -1053,21 +1053,23 @@ }; -tProgramDlg::tProgramDlg(tProgram *e, JZPianoWindow* w, JZTrack *t) - : tEventDlg(e, w, t), - Program(e->Program + 1)//, +tProgramDlg::tProgramDlg(tProgram* pProgram, JZPianoWindow* w, JZTrack *t) + : tEventDlg(pProgram, w, t), + Program(pProgram->GetProgram() + 1)//, // Choice("Program", &gpConfig->GetVoiceName(0), &Program) { - Event = e; + Event = pProgram; } bool tProgramDlg::OnClose() { - //Choice.GetValue(); +// Choice.GetValue(); if (Program <= 0) + { Program = 1; - ((tProgram *)Copy)->Program = Program - 1; + } + ((tProgram *)Copy)->SetProgram(Program - 1); return tEventDlg::OnClose(); } Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-05-21 15:51:25 UTC (rev 551) +++ trunk/jazz/src/Events.h 2008-05-22 05:26:26 UTC (rev 552) @@ -851,17 +851,15 @@ { public: - unsigned char Program; - - tProgram(int clk, int cha, unsigned char prg) - : tChannelEvent(clk, StatProgram, cha) + tProgram(int clk, int Channel, unsigned char Program) + : tChannelEvent(clk, StatProgram, Channel) { - Program = prg; + mProgram = Program; } virtual int Write(JZWriteBase &io) { - edb(); return io.Write(this, Program); + edb(); return io.Write(this, mProgram); } virtual tProgram* IsProgram() @@ -879,19 +877,19 @@ virtual int GetValue() const { edb(); - return Program; + return mProgram; } virtual int GetPitch() const { edb(); - return Program; + return mProgram; } - virtual void SetPitch(int p) + virtual void SetPitch(int Pitch) { edb(); - Program = p; + mProgram = Pitch; } virtual const wxPen* GetPen() const @@ -903,6 +901,20 @@ { return wxGREEN_BRUSH; } + + unsigned char GetProgram() const + { + return mProgram; + } + + void SetProgram(unsigned char Program) + { + mProgram = Program; + } + + private: + + unsigned char mProgram; }; Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-05-21 15:51:25 UTC (rev 551) +++ trunk/jazz/src/Player.cpp 2008-05-22 05:26:26 UTC (rev 552) @@ -1650,8 +1650,8 @@ break; case StatProgram: { - tProgram *k = pEvent->IsProgram(); - SEQ_SET_PATCH(mididev, k->GetChannel(), k->Program); + tProgram* pProgram = pEvent->IsProgram(); + SEQ_SET_PATCH(mididev, pProgram->GetChannel(), pProgram->GetProgram()); if (now) seqbuf_flush_last_event(); } break; Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-05-21 15:51:25 UTC (rev 551) +++ trunk/jazz/src/Track.cpp 2008-05-22 05:26:26 UTC (rev 552) @@ -2411,7 +2411,7 @@ { if (mPatch) { - return mPatch->Program + 1; + return mPatch->GetProgram() + 1; } return 0; } Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-21 15:51:25 UTC (rev 551) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-22 05:26:26 UTC (rev 552) @@ -285,15 +285,15 @@ case StatProgram: { - tProgram *k = pEvent->IsProgram(); - u.c[0] = 0xC0 | k->GetChannel(); - u.c[1] = k->Program; + tProgram* pProgram = pEvent->IsProgram(); + u.c[0] = 0xC0 | pProgram->GetChannel(); + u.c[1] = pProgram->GetProgram(); } break; case StatChnPressure: { - tChnPressure *k = pEvent->IsChnPressure(); + tChnPressure* k = pEvent->IsChnPressure(); u.c[0] = 0xC0 | k->GetChannel(); u.c[1] = k->Value; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-22 05:38:57
|
Revision: 553 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=553&view=rev Author: pstieber Date: 2008-05-21 22:38:45 -0700 (Wed, 21 May 2008) Log Message: ----------- Started using accessors in the tKeyOff event class. Modified Paths: -------------- trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/Events.h trunk/jazz/src/Player.cpp trunk/jazz/src/StandardFile.cpp trunk/jazz/src/Track.cpp trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-05-22 05:26:26 UTC (rev 552) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-05-22 05:38:45 UTC (rev 553) @@ -425,8 +425,8 @@ tKeyOff* pKeyOff = pEvent->IsKeyOff(); set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_NOTEOFF); ev.data.note.channel = pKeyOff->GetChannel(); - ev.data.note.note = pKeyOff->Key; - ev.data.note.velocity = pKeyOff->OffVeloc; + ev.data.note.note = pKeyOff->GetKey(); + ev.data.note.velocity = pKeyOff->GetOffVelocity(); rc = write(&ev, now); } break; Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-05-22 05:26:26 UTC (rev 552) +++ trunk/jazz/src/Events.h 2008-05-22 05:38:45 UTC (rev 553) @@ -525,8 +525,8 @@ { public: - tChannelEvent(int clk, unsigned char sta, int Channel) - : JZEvent(clk, sta) + tChannelEvent(int Clock, unsigned char sta, int Channel) + : JZEvent(Clock, sta) { mChannel = Channel; } @@ -567,12 +567,12 @@ public: tKeyOn( - int clk, - int cha, + int Clock, + int Channel, unsigned char Key, unsigned char Velocity, unsigned short Length = 0) - : tChannelEvent(clk, StatKeyOn, cha), + : tChannelEvent(Clock, StatKeyOn, Channel), mKey(Key), mVelocity(Velocity), mLength(Length), @@ -689,20 +689,21 @@ class tKeyOff : public tChannelEvent { public: - unsigned char Key; - // SN++ - unsigned char OffVeloc; - - tKeyOff(int clk, int cha, unsigned char key, unsigned char veloc = 0) - : tChannelEvent(clk, StatKeyOff, cha) + tKeyOff( + int Clock, + int Channel, + unsigned char Key, + unsigned char OffVelocity = 0) + : tChannelEvent(Clock, StatKeyOff, Channel), + mKey(Key), + mOffVelocity(OffVelocity) { - Key = key; - OffVeloc = veloc; } virtual int Write(JZWriteBase &io) { - edb(); return io.Write(this, Key, OffVeloc); + edb(); + return io.Write(this, mKey, mOffVelocity); } virtual tKeyOff* IsKeyOff() @@ -716,6 +717,27 @@ edb(); return new tKeyOff(*this); } + + unsigned char GetKey() const + { + return mKey; + } + + void SetKey(unsigned char Key) + { + mKey = Key; + } + + unsigned char GetOffVelocity() const + { + return mOffVelocity; + } + + private: + + unsigned char mKey; + + unsigned char mOffVelocity; }; @@ -724,14 +746,18 @@ public: short Value; - tPitch(int clk, unsigned short cha, unsigned char lo, unsigned char hi) - : tChannelEvent(clk, StatPitch, cha) + tPitch( + int Clock, + unsigned short Channel, + unsigned char lo, + unsigned char hi) + : tChannelEvent(Clock, StatPitch, Channel) { Value = ((hi << 7) | lo) - 8192; } - tPitch(int clk, unsigned short cha, short val) - : tChannelEvent(clk, StatPitch, cha) + tPitch(int Clock, unsigned short Channel, short val) + : tChannelEvent(Clock, StatPitch, Channel) { Value = val; } @@ -792,8 +818,12 @@ unsigned char mControl; unsigned char mValue; - tControl(int clk, int cha, unsigned char ctl, unsigned char val) - : tChannelEvent(clk, StatControl, cha) + tControl( + int Clock, + int Channel, + unsigned char ctl, + unsigned char val) + : tChannelEvent(Clock, StatControl, Channel) { mControl = ctl; mValue = val; @@ -851,8 +881,8 @@ { public: - tProgram(int clk, int Channel, unsigned char Program) - : tChannelEvent(clk, StatProgram, Channel) + tProgram(int Clock, int Channel, unsigned char Program) + : tChannelEvent(Clock, StatProgram, Channel) { mProgram = Program; } @@ -927,11 +957,11 @@ unsigned short Length; tMetaEvent( - int clk, + int Clock, unsigned char sta, unsigned char* dat, unsigned short len) - : JZEvent(clk, sta) + : JZEvent(Clock, sta) { Length = len; mpData = new unsigned char [len + 1]; @@ -973,8 +1003,8 @@ // the file. public: enum { DATALEN = 20 }; - tJazzMeta(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatJazzMeta, dat, len) + tJazzMeta(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatJazzMeta, dat, len) { } tJazzMeta() @@ -1041,8 +1071,8 @@ { public: - tSysEx(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatSysEx, dat, len) + tSysEx(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatSysEx, dat, len) { } @@ -1066,8 +1096,8 @@ { public: - tSongPtr(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatSongPtr, dat, len) + tSongPtr(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatSongPtr, dat, len) { } @@ -1087,13 +1117,13 @@ class tMidiClock : public tMetaEvent { public: - tMidiClock(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatMidiClock, dat, len) + tMidiClock(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatMidiClock, dat, len) { } - tMidiClock(int clk) - : tMetaEvent(clk, StatMidiClock, 0, 0) + tMidiClock(int Clock) + : tMetaEvent(Clock, StatMidiClock, 0, 0) { } @@ -1113,14 +1143,17 @@ class tStartPlay : public tMetaEvent { public: - tStartPlay(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatStartPlay, dat, len) + + tStartPlay(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatStartPlay, dat, len) { } - tStartPlay(int clk) - : tMetaEvent(clk, StatStartPlay, 0, 0) + + tStartPlay(int Clock) + : tMetaEvent(Clock, StatStartPlay, 0, 0) { } + virtual tStartPlay* IsStartPlay() { edb(); @@ -1137,13 +1170,14 @@ class tContPlay : public tMetaEvent { public: - tContPlay(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatContPlay, dat, len) + + tContPlay(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatContPlay, dat, len) { } - tContPlay(int clk) - : tMetaEvent(clk, StatContPlay, 0, 0) + tContPlay(int Clock) + : tMetaEvent(Clock, StatContPlay, 0, 0) { } @@ -1164,13 +1198,13 @@ { public: - tStopPlay(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatStopPlay, dat, len) + tStopPlay(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatStopPlay, dat, len) { } - tStopPlay(int clk) - : tMetaEvent(clk, StatStopPlay, 0, 0) + tStopPlay(int Clock) + : tMetaEvent(Clock, StatStopPlay, 0, 0) { } @@ -1190,14 +1224,17 @@ class tText : public tMetaEvent { public: - tText(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatText, dat, len) + + tText(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatText, dat, len) { } - tText(int clk, unsigned char *dat) - : tMetaEvent(clk, StatText, dat, strlen((const char*)dat)) + + tText(int Clock, unsigned char *dat) + : tMetaEvent(Clock, StatText, dat, strlen((const char*)dat)) { } + virtual tText* IsText() { edb(); @@ -1222,8 +1259,8 @@ { public: - tCopyright(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatCopyright, dat, len) + tCopyright(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatCopyright, dat, len) { } @@ -1244,8 +1281,8 @@ { public: - tTrackName(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatTrackName, dat, len) + tTrackName(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatTrackName, dat, len) { // SN++ Diese Restriktion ist viel zu hart. Es genuegt, den Namen im Mixerdialog // zu begrenzen!!! @@ -1280,8 +1317,8 @@ { public: - tMarker(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatMarker, dat, len) + tMarker(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatMarker, dat, len) { } @@ -1318,8 +1355,8 @@ // that seems to be for serialization. int eventlength; - tPlayTrack(int clk, unsigned char *chardat, unsigned short len) - : tMetaEvent(clk, StatPlayTrack, chardat, len) + tPlayTrack(int Clock, unsigned char *chardat, unsigned short len) + : tMetaEvent(Clock, StatPlayTrack, chardat, len) { int *dat = (int *)chardat; @@ -1335,8 +1372,8 @@ } } - tPlayTrack(int clk, int track, int transpose, int eventlength) - : tMetaEvent(clk, StatPlayTrack, 0, 0) + tPlayTrack(int Clock, int track, int transpose, int eventlength) + : tMetaEvent(Clock, StatPlayTrack, 0, 0) { this->track=track; this->transpose=transpose; @@ -1391,11 +1428,11 @@ int uSec; tSetTempo( - int clk, + int Clock, unsigned char Character1, unsigned char Character2, unsigned char Character3) - : JZEvent(clk, StatSetTempo) + : JZEvent(Clock, StatSetTempo) { uSec = ((unsigned)Character1 << 16L) + @@ -1403,8 +1440,8 @@ Character3; } - tSetTempo(int clk, int bpm) - : JZEvent(clk, StatSetTempo) + tSetTempo(int Clock, int bpm) + : JZEvent(Clock, StatSetTempo) { SetBPM(bpm); } @@ -1448,8 +1485,8 @@ class tMtcOffset : public tMetaEvent { public: - tMtcOffset(int clk, unsigned char *dat, unsigned short len) - : tMetaEvent(clk, StatMtcOffset, dat, len) + tMtcOffset(int Clock, unsigned char *dat, unsigned short len) + : tMetaEvent(Clock, StatMtcOffset, dat, len) { } virtual tMtcOffset* IsMtcOffset() @@ -1473,12 +1510,12 @@ unsigned char Numerator, Denomiator, Clocks, Quarter; tTimeSignat( - int clk, + int Clock, unsigned char Character1, unsigned char Character2, unsigned char Character3 = 24, unsigned char Character4 = 8) - : JZEvent(clk, StatTimeSignat) + : JZEvent(Clock, StatTimeSignat) { Numerator = Character1; Denomiator = Character2; @@ -1518,8 +1555,8 @@ { public: - tEndOfTrack(int clk) - : JZEvent(clk, StatEndOfTrack) + tEndOfTrack(int Clock) + : JZEvent(Clock, StatEndOfTrack) { } @@ -1549,8 +1586,8 @@ int Sharps; int Minor; - tKeySignat(int clk, int Character1, int Character2) - : JZEvent(clk, StatKeySignat) + tKeySignat(int Clock, int Character1, int Character2) + : JZEvent(Clock, StatKeySignat) { Sharps = Character1; Minor = Character2; @@ -1581,8 +1618,12 @@ short Value; short Key; - tKeyPressure(int clk, unsigned short cha, unsigned char key, unsigned char val) - : tChannelEvent(clk, StatKeyPressure, cha) + tKeyPressure( + int Clock, + unsigned short Channel, + unsigned char key, + unsigned char val) + : tChannelEvent(Clock, StatKeyPressure, Channel) { Value = val; Key = key; @@ -1630,8 +1671,8 @@ public: unsigned char Value; - tChnPressure(int clk, int cha, unsigned char val) - : tChannelEvent(clk, StatChnPressure, cha) + tChnPressure(int Clock, int Channel, unsigned char val) + : tChannelEvent(Clock, StatChnPressure, Channel) { Value = val; } Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-05-22 05:26:26 UTC (rev 552) +++ trunk/jazz/src/Player.cpp 2008-05-22 05:38:45 UTC (rev 553) @@ -506,7 +506,7 @@ // SN++ Patch: Notes off for not GM/GS devices int ii; - tKeyOff off(0, 0, 0); + tKeyOff pKeyOff(0, 0, 0); for (ii = 0; ii < Song->GetTrackCount(); ii++) { @@ -522,9 +522,9 @@ { if (pKeyOn->GetClock() + pKeyOn->GetEventLength() >= Clock - 100) { - off.SetChannel(pKeyOn->GetChannel()); - off.Key = pKeyOn->GetKey(); - OutNow(&off); + pKeyOff.SetChannel(pKeyOn->GetChannel()); + pKeyOff.SetKey(pKeyOn->GetKey()); + OutNow(&pKeyOff); } } pEvent = Iterator.Next(); Modified: trunk/jazz/src/StandardFile.cpp =================================================================== --- trunk/jazz/src/StandardFile.cpp 2008-05-22 05:26:26 UTC (rev 552) +++ trunk/jazz/src/StandardFile.cpp 2008-05-22 05:38:45 UTC (rev 553) @@ -247,7 +247,7 @@ // KeyOff -> KeyOn mit Vel=0. Gives better Runningstatus! case StatKeyOff: // SN-- only if KeyOff veloc is zero - if (!pEvent->IsKeyOff()->OffVeloc) + if (!pEvent->IsKeyOff()->GetOffVelocity()) { Stat = StatKeyOn | pEvent->IsChannelEvent()->GetChannel(); if (Stat != RunningStatus) Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-05-22 05:26:26 UTC (rev 552) +++ trunk/jazz/src/Track.cpp 2008-05-22 05:38:45 UTC (rev 553) @@ -1243,7 +1243,7 @@ if ( pKeyOff && !pKeyOff->IsKilled() && - pKeyOn->GetKey() == pKeyOff->Key && + pKeyOn->GetKey() == pKeyOff->GetKey() && pKeyOn->GetChannel() == pKeyOff->GetChannel()) { pKeyOn->SetLength(pKeyOff->GetClock() - pKeyOn->GetClock()); Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-22 05:26:26 UTC (rev 552) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-22 05:38:45 UTC (rev 553) @@ -278,7 +278,7 @@ { tKeyOff* pKeyOff = pEvent->IsKeyOff(); u.c[0] = 0x80 | pKeyOff->GetChannel(); - u.c[1] = pKeyOff->Key; + u.c[1] = pKeyOff->GetKey(); u.c[2] = 0; } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-22 18:16:42
|
Revision: 558 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=558&view=rev Author: pstieber Date: 2008-05-22 11:16:07 -0700 (Thu, 22 May 2008) Log Message: ----------- Encapsulated the mControl and mValue data members of the tControl class. Modified Paths: -------------- trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/Command.cpp trunk/jazz/src/ControlEdit.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Events.h trunk/jazz/src/Player.cpp trunk/jazz/src/Track.cpp trunk/jazz/src/Track.h trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-05-22 16:10:26 UTC (rev 557) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-05-22 18:16:07 UTC (rev 558) @@ -467,8 +467,8 @@ tControl *k = pEvent->IsControl(); set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_CONTROLLER); ev.data.control.channel = k->GetChannel(); - ev.data.control.param = k->mControl; - ev.data.control.value = k->mValue; + ev.data.control.param = k->GetControl(); + ev.data.control.value = k->GetControlValue(); rc = write(&ev, now); } break; Modified: trunk/jazz/src/Command.cpp =================================================================== --- trunk/jazz/src/Command.cpp 2008-05-22 16:10:26 UTC (rev 557) +++ trunk/jazz/src/Command.cpp 2008-05-22 18:16:07 UTC (rev 558) @@ -766,10 +766,10 @@ tControl* pControl = pEvent->IsControl(); if (pControl) { - if (pControl->mControl == fr) + if (pControl->GetControl() == fr) { tControl* pControlCopy = (tControl *)pControl->Copy(); - pControlCopy->mControl = to; + pControlCopy->SetControl(to); pTrack->Kill(pControl); pTrack->Put(pControlCopy); } Modified: trunk/jazz/src/ControlEdit.cpp =================================================================== --- trunk/jazz/src/ControlEdit.cpp 2008-05-22 16:10:26 UTC (rev 557) +++ trunk/jazz/src/ControlEdit.cpp 2008-05-22 18:16:07 UTC (rev 558) @@ -314,10 +314,12 @@ { if (IsCtrlEdit(pEvent)) { - if (Clock2Val(pEvent->GetClock()) != pEvent->IsControl()->mValue) + if ( + Clock2Val(pEvent->GetClock()) != + pEvent->IsControl()->GetControlValue()) { pControlCopy = pEvent->Copy()->IsControl(); - pControlCopy->mValue = Clock2Val(pEvent->GetClock()); + pControlCopy->SetControlValue(Clock2Val(pEvent->GetClock())); track->Kill(pEvent); track->Put(pControlCopy); } @@ -471,12 +473,12 @@ int tCtrlEdit::IsCtrlEdit(JZEvent* pEvent) { tControl* pControl = pEvent->IsControl(); - return (pControl && pControl->mControl == ctrl_num); + return (pControl && pControl->GetControl() == ctrl_num); } int tCtrlEdit::GetValue(JZEvent* pEvent) { - return pEvent->IsControl()->mValue; + return pEvent->IsControl()->GetControlValue(); } JZEvent * tCtrlEdit::NewEvent(long clock, int val) Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2008-05-22 16:10:26 UTC (rev 557) +++ trunk/jazz/src/Dialogs.cpp 2008-05-22 18:16:07 UTC (rev 558) @@ -848,21 +848,21 @@ }; -tControlDlg::tControlDlg(tControl *e, JZPianoWindow* w, JZTrack *t) - : tChEventDlg(e, w, t)//, +tControlDlg::tControlDlg(tControl* pControl, JZPianoWindow* w, JZTrack *t) + : tChEventDlg(pControl, w, t)//, // Choice("Controller", &gpConfig->GetCtrlName(0), &Control) { - Event = e; - Value = e->mValue; - Control = e->mControl + 1; + Event = pControl; + Value = pControl->GetControlValue(); + Control = pControl->GetControl() + 1; } bool tControlDlg::OnClose() { - ((tControl *)Copy)->mValue = Value; + ((tControl *)Copy)->SetControlValue(Value); // Choice.GetValue(); - ((tControl *)Copy)->mControl = Control - 1; + ((tControl *)Copy)->SetControl(Control - 1); return tChEventDlg::OnClose(); } Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-05-22 16:10:26 UTC (rev 557) +++ trunk/jazz/src/Events.h 2008-05-22 18:16:07 UTC (rev 558) @@ -338,8 +338,6 @@ } #endif - public: - unsigned char GetStat() const { return mStat; @@ -349,23 +347,24 @@ { return mClock & ~KILLED_CLOCK; } - void SetClock(int c) + + void SetClock(int Clock) { - mClock = c; + mClock = Clock; } - // the device is dynamically set when events are copied to - // the playback queue (from the track device) + // The device is dynamically set when events are copied to the playback + // queue (from the track device). enum { BROADCAST_DEVICE = 0 }; JZEvent(int Clock, unsigned char Stat) + : mStat(Stat), + mClock(Clock), + mDevice(BROADCAST_DEVICE) { - mClock = Clock; - mStat = Stat; - mDevice = BROADCAST_DEVICE; #ifdef E_DBUG Magic = MAGIC; #endif @@ -515,12 +514,13 @@ int mClock; - private: + private: int mDevice; }; - +//***************************************************************************** +//***************************************************************************** class tChannelEvent : public JZEvent { public: @@ -558,8 +558,6 @@ unsigned char mChannel; }; - - //***************************************************************************** //***************************************************************************** class tKeyOn : public tChannelEvent @@ -685,7 +683,8 @@ unsigned short mOffVelocity; }; - +//***************************************************************************** +//***************************************************************************** class tKeyOff : public tChannelEvent { public: @@ -740,7 +739,8 @@ unsigned char mOffVelocity; }; - +//***************************************************************************** +//***************************************************************************** class tPitch : public tChannelEvent { public: @@ -809,27 +809,24 @@ } }; - - +//***************************************************************************** +//***************************************************************************** class tControl : public tChannelEvent { public: - unsigned char mControl; - unsigned char mValue; - tControl( int Clock, int Channel, - unsigned char ctl, - unsigned char val) - : tChannelEvent(Clock, StatControl, Channel) + unsigned char Control, + unsigned char Value) + : tChannelEvent(Clock, StatControl, Channel), + mControl(Control), + mValue(Value) { - mControl = ctl; - mValue = val; } - virtual int Write(JZWriteBase &io) + virtual int Write(JZWriteBase& io) { edb(); return io.Write(this, mControl, mValue); @@ -859,10 +856,10 @@ return mControl; } - virtual void SetPitch(int p) + virtual void SetPitch(int Pitch) { edb(); - mControl = p; + mControl = Pitch; } virtual const wxPen* GetPen() const @@ -874,6 +871,31 @@ { return wxCYAN_BRUSH; } + + unsigned char GetControl() const + { + return mControl; + } + + void SetControl(unsigned char Control) + { + mControl = Control; + } + + unsigned char GetControlValue() const + { + return mValue; + } + + void SetControlValue(unsigned char Value) + { + mValue = Value; + } + + private: + + unsigned char mControl; + unsigned char mValue; }; @@ -1525,7 +1547,8 @@ virtual int Write(JZWriteBase &io) { - edb(); return io.Write(this, Numerator, Denomiator, Clocks, Quarter); + edb(); + return io.Write(this, Numerator, Denomiator, Clocks, Quarter); } virtual tTimeSignat* IsTimeSignat() @@ -1550,7 +1573,8 @@ } }; -//end of track JAVE new event(it is a standard type, i want it to define track loop points, as defined by the midi standard) +// End of track JAVE new event(it is a standard type, i want +// it to define track loop points, as defined by the midi standard) class tEndOfTrack : public JZEvent { public: @@ -1699,13 +1723,18 @@ edb(); return Value; } + virtual int GetPitch() const { edb(); return 0; } - virtual void SetPitch(int v) { edb(); } + virtual void SetPitch(int v) + { + edb(); + } + virtual const wxPen* GetPen() const { return wxGREEN_PEN; Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-05-22 16:10:26 UTC (rev 557) +++ trunk/jazz/src/Player.cpp 2008-05-22 18:16:07 UTC (rev 558) @@ -1633,7 +1633,10 @@ pKeyOn->GetChannel(), pKeyOn->GetKey(), pKeyOn->GetVelocity()); - if (now) seqbuf_flush_last_event(); + if (now) + { + seqbuf_flush_last_event(); + } } break; @@ -1645,14 +1648,20 @@ pKeyOff->GetChannel(), pKeyOff->GetKey(), pKeyOff->GetOffVelocity()); - if (now) seqbuf_flush_last_event(); + if (now) + { + seqbuf_flush_last_event(); + } } break; case StatProgram: { tProgram* pProgram = pEvent->IsProgram(); SEQ_SET_PATCH(mididev, pProgram->GetChannel(), pProgram->GetProgram()); - if (now) seqbuf_flush_last_event(); + if (now) + { + seqbuf_flush_last_event(); + } } break; @@ -1661,7 +1670,10 @@ { tKeyPressure *k = pEvent->IsKeyPressure(); SEQ_KEY_PRESSURE(mididev, k->GetChannel(), k->Key, k->Value); - if (now) seqbuf_flush_last_event(); + if (now) + { + seqbuf_flush_last_event(); + } } break; // @@ -1670,15 +1682,21 @@ { tChnPressure *k = pEvent->IsChnPressure(); SEQ_CHN_PRESSURE(mididev, k->GetChannel(), k->Value); - if (now) seqbuf_flush_last_event(); + if (now) + { + seqbuf_flush_last_event(); + } } break; case StatControl: { tControl *k = pEvent->IsControl(); - SEQ_CONTROL(mididev, k->GetChannel(), k->mControl, k->mValue); - if (now) seqbuf_flush_last_event(); + SEQ_CONTROL(mididev, k->GetChannel(), k->GetControl(), k->GetControlValue()); + if (now) + { + seqbuf_flush_last_event(); + } } break; @@ -1686,7 +1704,10 @@ { tPitch *k = pEvent->IsPitch(); SEQ_BENDER(mididev, k->GetChannel(), k->Value + 8192); - if (now) seqbuf_flush_last_event(); + if (now) + { + seqbuf_flush_last_event(); + } } break; Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-05-22 16:10:26 UTC (rev 557) +++ trunk/jazz/src/Track.cpp 2008-05-22 18:16:07 UTC (rev 558) @@ -246,14 +246,14 @@ } tDrumInstrumentParameter::tDrumInstrumentParameter(tNrpn *par) - : mPitch(par->mLsb.mValue), + : mPitch(par->mLsb.GetControlValue()), mpNext(0) { for (int i = drumPitchIndex; i < numDrumParameters; i++) { param[i] = 0; } - param[drumParam2Index(par->mMsb.mValue)] = par; + param[drumParam2Index(par->mMsb.GetControlValue())] = par; } tNrpn *tDrumInstrumentParameter::Get(int index) @@ -264,7 +264,7 @@ void tDrumInstrumentParameter::Put(tNrpn *par) { - param[par->mLsb.mValue] = par; + param[par->mLsb.GetControlValue()] = par; } tDrumInstrumentParameter *tDrumInstrumentParameter::Next() @@ -304,7 +304,7 @@ void tDrumInstrumentParameterList::PutParam(tNrpn *par) { - tDrumInstrumentParameter* ptr = GetElem(par->mLsb.mValue); + tDrumInstrumentParameter* ptr = GetElem(par->mLsb.GetControlValue()); if (!ptr) { ptr = new tDrumInstrumentParameter(par); @@ -313,7 +313,7 @@ } else { - ptr->param[drumParam2Index(par->mMsb.mValue)] = par; + ptr->param[drumParam2Index(par->mMsb.GetControlValue())] = par; } } @@ -847,7 +847,7 @@ } if ((pControl = e->IsControl()) != 0) { - switch (pControl->mControl) + switch (pControl->GetControl()) { case 0x07: if (!Volume) @@ -1388,7 +1388,7 @@ WrittenBefore = 0; if (e->IsControl()) { - switch (e->IsControl()->mControl) + switch (e->IsControl()->GetControl()) { // Don't write these again if present as events // and clock == 0 (should not happen) @@ -1459,22 +1459,22 @@ } if (e->IsControl()) { - switch (e->IsControl()->mControl) + switch (e->IsControl()->GetControl()) { // Grab Rpn/Nrpn/Bank from file and save them, don't put // them into event-array case 0x63: case 0x65: - Msb = e->IsControl()->mValue; // Rpn/Nrpn Msb + Msb = e->IsControl()->GetControlValue(); // Rpn/Nrpn Msb SpecialEvent = 1; break; case 0x62: case 0x64: - Lsb = e->IsControl()->mValue; // Rpn/Nrpn Lsb + Lsb = e->IsControl()->GetControlValue(); // Rpn/Nrpn Lsb SpecialEvent = 1; break; case 0x06: - Data = e->IsControl()->mValue; // Rpn/Nrpn Data + Data = e->IsControl()->GetControlValue(); // Rpn/Nrpn Data SpecialEvent = 1; cha = e->IsControl()->GetChannel(); switch (Msb) @@ -2171,7 +2171,7 @@ { if (Volume) { - return Volume->mValue + 1; + return Volume->GetControlValue() + 1; } return 0; } @@ -2193,13 +2193,17 @@ bool JZTrack::DecreaseVolume() { - if (Volume && Volume->mValue > 0) + if (Volume && Volume->GetControlValue() > 0) { Kill(Volume); - --Volume->mValue; + Volume->SetControlValue(Volume->GetControlValue() - 1); - JZEvent* pEvent = new tControl(0, Channel - 1, 0x07, Volume->mValue); + JZEvent* pEvent = new tControl( + 0, + Channel - 1, + 0x07, + Volume->GetControlValue()); Put(pEvent); gpMidiPlayer->OutNow(this, pEvent); @@ -2212,13 +2216,18 @@ bool JZTrack::IncreaseVolume() { - if (Volume && Volume->mValue < 127) + if (Volume && Volume->GetControlValue() < 127) { Kill(Volume); - ++Volume->mValue; + Volume->SetControlValue(Volume->GetControlValue() + 1); - JZEvent* pEvent = new tControl(0, Channel - 1, 0x07, Volume->mValue); + JZEvent* pEvent = new tControl( + 0, + Channel - 1, + 0x07, + Volume->GetControlValue()); + Put(pEvent); gpMidiPlayer->OutNow(this, pEvent); @@ -2235,7 +2244,7 @@ { if (Pan) { - return Pan->mValue + 1; + return Pan->GetControlValue() + 1; } return 0; } @@ -2261,7 +2270,7 @@ { if (Reverb) { - return Reverb->mValue + 1; + return Reverb->GetControlValue() + 1; } return 0; } @@ -2287,7 +2296,7 @@ { if (Chorus) { - return Chorus->mValue + 1; + return Chorus->GetControlValue() + 1; } return 0; } @@ -2317,7 +2326,7 @@ if (mpBank) { DEBUG(fprintf(stderr,"Bank %d selected.\n\n",mpBank->Value);) - return mpBank->mValue; + return mpBank->GetControlValue(); } else { @@ -2330,8 +2339,8 @@ for (int i=0; gpConfig->BankEntry(i).Command[0]>=0; i++) { if ( - gpConfig->BankEntry(i).Command[0] == mpBank->mValue && - gpConfig->BankEntry(i).Command[1] == mpBank2->mValue) + gpConfig->BankEntry(i).Command[0] == mpBank->GetControlValue() && + gpConfig->BankEntry(i).Command[1] == mpBank2->GetControlValue()) { DEBUG(fprintf(stderr,"Bank %d selected.\n\n",i);) return i; Modified: trunk/jazz/src/Track.h =================================================================== --- trunk/jazz/src/Track.h 2008-05-22 16:10:26 UTC (rev 557) +++ trunk/jazz/src/Track.h 2008-05-22 18:16:07 UTC (rev 558) @@ -101,7 +101,7 @@ virtual int GetVal() { - return mDataMsb.mValue; + return mDataMsb.GetValue(); } tControl mMsb; Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-22 16:10:26 UTC (rev 557) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-22 18:16:07 UTC (rev 558) @@ -303,8 +303,8 @@ { tControl* pControl = pEvent->IsControl(); u.c[0] = 0xB0 | pControl->GetChannel(); - u.c[1] = pControl->mControl; - u.c[2] = pControl->mValue; + u.c[1] = pControl->GetControl(); + u.c[2] = pControl->GetControlValue(); } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-24 19:03:35
|
Revision: 562 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=562&view=rev Author: pstieber Date: 2008-05-24 12:03:32 -0700 (Sat, 24 May 2008) Log Message: ----------- 1. Changed tMetaEvent::pData to tMetaEvent::mpData and tMetaEvent::Length to tMetaEvent::mLength. 2. Encapsulated the mLength and mpData data members in tMetaEvent by making them protected and adding GetData, and GetDataLength. 3. Added FixCheckSum to tMetaEvent, and called it from 4. Added some class comment headers. 5. Changed tEventArray::mName to tEventArray::mpName. 6. Changed tSynthSysex::GetValPtr and tSynthSysex::GetChaPtr to return constant pointers. This *will break the Linux build*, but I will fix this soon. Modified Paths: -------------- trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Events.cpp trunk/jazz/src/Events.h trunk/jazz/src/Synth.cpp trunk/jazz/src/Synth.h trunk/jazz/src/Track.cpp trunk/jazz/src/Track.h trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-05-24 18:53:41 UTC (rev 561) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-05-24 19:03:32 UTC (rev 562) @@ -495,14 +495,18 @@ case StatSysEx: { - tSysEx *s = pEvent->IsSysEx(); + tSysEx* pSysEx = pEvent->IsSysEx(); // prepend 0xf0 - char *buf = new char[s->Length + 1]; - buf[0] = 0xF0; - memcpy(buf + 1, s->mpData, s->Length); - set_event_header(&ev, pEvent->GetClock(), s->Length + 1, buf); + char* pBuffer = new char[pSysEx->GetDataLength() + 1]; + pBuffer[0] = 0xF0; + memcpy(pBuffer + 1, pSysEx->GetData(), pSysEx->GetDataLength()); + set_event_header( + &ev, + pEvent->GetClock(), + pSysEx->GetDataLength() + 1, + pBuffer); rc = write(&ev, now); - delete [] buf; + delete [] pBuffer; } break; Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2008-05-24 18:53:41 UTC (rev 561) +++ trunk/jazz/src/Dialogs.cpp 2008-05-24 19:03:32 UTC (rev 562) @@ -1140,21 +1140,24 @@ }; -tSysexDlg::tSysexDlg(tSysEx *s, JZPianoWindow* w, JZTrack *t) - : tEventDlg(s, w, t) +tSysexDlg::tSysexDlg(tSysEx* pSysEx, JZPianoWindow* w, JZTrack *t) + : tEventDlg(pSysEx, w, t) { - Event = s; + Event = pSysEx; char hexbyte[10]; str = new char[256]; str[0] = 0; - if (s->Length) - strcat( str, "f0 " ); + if (pSysEx->GetDataLength()) + { + strcat(str, "f0 "); + } - for (int i = 0; i < s->Length; i++) + const unsigned char* pData = pSysEx->GetData(); + for (int i = 0; i < pSysEx->GetDataLength(); i++) { - sprintf(hexbyte, "%02x ", s->mpData[i]); + sprintf(hexbyte, "%02x ", pData[i]); strcat(str, hexbyte); } } @@ -1223,9 +1226,8 @@ void tSysexDlg::AddProperties() { // char label1[100]; - unsigned char* uptr; - if (Event->IsSysEx()->Length) + if (Event->IsSysEx()->GetDataLength()) { // sprintf( // label1, @@ -1240,16 +1242,16 @@ Event->IsSysEx()))), "string"));//r/o - uptr = gpSynth->GetSysexValPtr(Event->IsSysEx()); + const unsigned char* pData = gpSynth->GetSysexValPtr(Event->IsSysEx()); - if (uptr) + if (pData) { ostringstream Oss; Oss << "First data byte is at offset " - << uptr - Event->IsSysEx()->mpData + 1 << ", value " - << setw(2) << hex << static_cast<int>(*uptr) - << dec << " (" << static_cast<int>(*uptr) << " decimal)"; + << pData - Event->IsSysEx()->GetData() + 1 << ", value " + << setw(2) << hex << static_cast<int>(*pData) + << dec << " (" << static_cast<int>(*pData) << " decimal)"; sheet->AddProperty(new wxProperty( Oss.str().c_str(), wxPropertyValue((char*)""), Modified: trunk/jazz/src/Events.cpp =================================================================== --- trunk/jazz/src/Events.cpp 2008-05-24 18:53:41 UTC (rev 561) +++ trunk/jazz/src/Events.cpp 2008-05-24 19:03:32 UTC (rev 562) @@ -185,9 +185,30 @@ } //***************************************************************************** +// Description: +// This is the meta event class definition. //***************************************************************************** //----------------------------------------------------------------------------- +// Description: +// This function fixed the checksum bytes at the end of the data stream. //----------------------------------------------------------------------------- +void tMetaEvent::FixCheckSum() +{ + unsigned char Sum = 0x00; + for (unsigned short i = 4; i < (mLength - 2); ++i) + { + Sum += mpData[i]; + } + mpData[mLength - 2] = (0x80 - (Sum & 0x7f)) & 0x7f; + mpData[mLength - 1] = 0xf7; +} + +//***************************************************************************** +// Description: +// This is the System Exclusive (SysEx) event class definition. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSysEx::GetPitch() const { edb(); Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-05-24 18:53:41 UTC (rev 561) +++ trunk/jazz/src/Events.h 2008-05-24 19:03:32 UTC (rev 562) @@ -898,7 +898,8 @@ unsigned char mValue; }; - +//***************************************************************************** +//***************************************************************************** class tProgram : public tChannelEvent { public: @@ -969,27 +970,27 @@ unsigned char mProgram; }; - - +//***************************************************************************** +//***************************************************************************** class tMetaEvent : public JZEvent { public: - unsigned char* mpData; - unsigned short Length; - tMetaEvent( int Clock, unsigned char sta, - unsigned char* dat, - unsigned short len) - : JZEvent(Clock, sta) + unsigned char* pData, + unsigned short Length) + : JZEvent(Clock, sta), + mpData(0), + mLength(Length) { - Length = len; - mpData = new unsigned char [len + 1]; - if (dat) - memcpy(mpData, dat, len); - mpData[len] = 0; + mpData = new unsigned char [Length + 1]; + if (pData) + { + memcpy(mpData, pData, Length); + } + mpData[Length] = 0; } virtual ~tMetaEvent() @@ -1000,7 +1001,7 @@ virtual int Write(JZWriteBase &io) { edb(); - return io.Write(this, mpData, Length); + return io.Write(this, mpData, mLength); } virtual tMetaEvent* IsMetaEvent() @@ -1012,23 +1013,47 @@ virtual JZEvent* Copy() const { edb(); - return new tMetaEvent(mClock, mStat, mpData, Length); + return new tMetaEvent(mClock, mStat, mpData, mLength); } -}; + const unsigned char* GetData() const + { + return mpData; + } + unsigned short GetDataLength() const + { + return mLength; + } + virtual void FixCheckSum(); + + protected: + + unsigned char* mpData; + unsigned short mLength; +}; + +//***************************************************************************** +// Description: +// This event contains proprietary information for Jazz++. This event +// should should not go into a track itself but is read/written from/to +// the file. +//***************************************************************************** class tJazzMeta : public tMetaEvent { - // proprietary information of jazz stored to a track. This event - // should not go into a track itself but is read/written from/to - // the file. public: - enum { DATALEN = 20 }; - tJazzMeta(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatJazzMeta, dat, len) + + enum { + DATALEN = 20 + }; + + tJazzMeta(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatJazzMeta, pData, Length) + { } + tJazzMeta() : tMetaEvent(0, StatJazzMeta, 0, DATALEN) { @@ -1036,18 +1061,22 @@ memcpy(mpData, "JAZ2", 4); mpData[4] = 1; // version or so } + char GetAudioMode() const { return mpData[5]; } + void SetAudioMode(char c) { mpData[5] = c; } + char GetTrackState() const { return mpData[6]; } + void SetTrackState(char c) { mpData[6] = c; @@ -1084,17 +1113,18 @@ virtual JZEvent* Copy() const { edb(); - return new tJazzMeta(mClock, mpData, Length); + return new tJazzMeta(mClock, mpData, mLength); } }; - +//***************************************************************************** +//***************************************************************************** class tSysEx : public tMetaEvent { public: - tSysEx(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatSysEx, dat, len) + tSysEx(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatSysEx, pData, Length) { } @@ -1107,19 +1137,21 @@ virtual JZEvent* Copy() const { edb(); - return new tSysEx(mClock, mpData, Length); + return new tSysEx(mClock, mpData, mLength); } // todo virtual int GetPitch() const; }; +//***************************************************************************** +//***************************************************************************** class tSongPtr : public tMetaEvent { public: - tSongPtr(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatSongPtr, dat, len) + tSongPtr(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatSongPtr, pData, Length) { } @@ -1132,15 +1164,17 @@ virtual JZEvent* Copy() const { edb(); - return new tSongPtr(mClock, mpData, Length); + return new tSongPtr(mClock, mpData, mLength); } }; +//***************************************************************************** +//***************************************************************************** class tMidiClock : public tMetaEvent { public: - tMidiClock(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatMidiClock, dat, len) + tMidiClock(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatMidiClock, pData, Length) { } @@ -1158,16 +1192,18 @@ virtual JZEvent* Copy() const { edb(); - return new tMidiClock(mClock, mpData, Length); + return new tMidiClock(mClock, mpData, mLength); } }; +//***************************************************************************** +//***************************************************************************** class tStartPlay : public tMetaEvent { public: - tStartPlay(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatStartPlay, dat, len) + tStartPlay(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatStartPlay, pData, Length) { } @@ -1185,16 +1221,18 @@ virtual JZEvent* Copy() const { edb(); - return new tStartPlay(mClock, mpData, Length); + return new tStartPlay(mClock, mpData, mLength); } }; +//***************************************************************************** +//***************************************************************************** class tContPlay : public tMetaEvent { public: - tContPlay(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatContPlay, dat, len) + tContPlay(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatContPlay, pData, Length) { } @@ -1212,16 +1250,18 @@ virtual JZEvent* Copy() const { edb(); - return new tContPlay(mClock, mpData, Length); + return new tContPlay(mClock, mpData, mLength); } }; +//***************************************************************************** +//***************************************************************************** class tStopPlay : public tMetaEvent { public: - tStopPlay(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatStopPlay, dat, len) + tStopPlay(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatStopPlay, pData, Length) { } @@ -1239,21 +1279,23 @@ virtual JZEvent* Copy() const { edb(); - return new tStopPlay(mClock, mpData, Length); + return new tStopPlay(mClock, mpData, mLength); } }; +//***************************************************************************** +//***************************************************************************** class tText : public tMetaEvent { public: - tText(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatText, dat, len) + tText(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatText, pData, Length) { } - tText(int Clock, unsigned char *dat) - : tMetaEvent(Clock, StatText, dat, strlen((const char*)dat)) + tText(int Clock, unsigned char* pData) + : tMetaEvent(Clock, StatText, pData, strlen((const char*)pData)) { } @@ -1266,7 +1308,7 @@ virtual JZEvent* Copy() const { edb(); - return new tText(mClock, mpData, Length); + return new tText(mClock, mpData, mLength); } virtual unsigned char* GetText() @@ -1275,14 +1317,14 @@ } }; - - +//***************************************************************************** +//***************************************************************************** class tCopyright : public tMetaEvent { public: - tCopyright(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatCopyright, dat, len) + tCopyright(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatCopyright, pData, Length) { } @@ -1295,23 +1337,25 @@ virtual JZEvent* Copy() const { edb(); - return new tCopyright(mClock, mpData, Length); + return new tCopyright(mClock, mpData, mLength); } }; +//***************************************************************************** +//***************************************************************************** class tTrackName : public tMetaEvent { public: - tTrackName(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatTrackName, dat, len) + tTrackName(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatTrackName, pData, Length) { // SN++ Diese Restriktion ist viel zu hart. Es genuegt, den Namen im Mixerdialog // zu begrenzen!!! /* #ifdef wx_motif // clip to 16 chars - if (len > 16) + if (Length > 16) { mpData[16] = 0; Length = 16; @@ -1329,18 +1373,18 @@ virtual JZEvent* Copy() const { edb(); - return new tTrackName(mClock, mpData, Length); + return new tTrackName(mClock, mpData, mLength); } }; - - +//***************************************************************************** +//***************************************************************************** class tMarker : public tMetaEvent { public: - tMarker(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatMarker, dat, len) + tMarker(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatMarker, pData, Length) { } @@ -1353,16 +1397,18 @@ virtual JZEvent* Copy() const { edb(); - return new tMarker(mClock, mpData, Length); + return new tMarker(mClock, mpData, mLength); } }; +//***************************************************************************** // the meaning of this event is to be able to reference a track and have that // play the instant the event is executed. You can also transpose the // referenced track and loop it for the duration of the playtrack event. This // makes it possible to compose in a structured fashion. // // Execution of the events takes place in song.cpp. +//***************************************************************************** class tPlayTrack : public tMetaEvent { public: @@ -1377,20 +1423,20 @@ // that seems to be for serialization. int eventlength; - tPlayTrack(int Clock, unsigned char *chardat, unsigned short len) - : tMetaEvent(Clock, StatPlayTrack, chardat, len) + tPlayTrack(int Clock, unsigned char *chardat, unsigned short Length) + : tMetaEvent(Clock, StatPlayTrack, chardat, Length) { - int *dat = (int *)chardat; + int* pData = (int *)chardat; // Fill in the fields from the data. track = 0; transpose = 0; eventlength = 0; - if (dat!=0) + if (pData != 0) { - track = dat[0]; - transpose = dat[1]; - eventlength = dat[2]; + track = pData[0]; + transpose = pData[1]; + eventlength = pData[2]; } } @@ -1410,16 +1456,16 @@ virtual int Write(JZWriteBase &io) { - mpData = new unsigned char [Length + 1]; - int* dat = (int *)mpData; - dat[0] = track; - dat[1] = transpose; - dat[2] = eventlength; - Length = sizeof(int) * 3; + mpData = new unsigned char [mLength + 1]; + int* pData = (int *)mpData; + pData[0] = track; + pData[1] = transpose; + pData[2] = eventlength; + mLength = sizeof(int) * 3; edb(); - mpData[Length] = 0; - return io.Write(this, mpData, Length); + mpData[mLength] = 0; + return io.Write(this, mpData, mLength); } virtual tPlayTrack* IsPlayTrack() @@ -1442,8 +1488,8 @@ } }; - - +//***************************************************************************** +//***************************************************************************** class tSetTempo : public JZEvent { public: @@ -1504,13 +1550,16 @@ } }; +//***************************************************************************** +//***************************************************************************** class tMtcOffset : public tMetaEvent { public: - tMtcOffset(int Clock, unsigned char *dat, unsigned short len) - : tMetaEvent(Clock, StatMtcOffset, dat, len) + tMtcOffset(int Clock, unsigned char* pData, unsigned short Length) + : tMetaEvent(Clock, StatMtcOffset, pData, Length) { } + virtual tMtcOffset* IsMtcOffset() { edb(); @@ -1520,11 +1569,12 @@ virtual JZEvent* Copy() const { edb(); - return new tMtcOffset(mClock, mpData, Length); + return new tMtcOffset(mClock, mpData, mLength); } }; - +//***************************************************************************** +//***************************************************************************** class tTimeSignat : public JZEvent { public: @@ -1573,8 +1623,9 @@ } }; -// End of track JAVE new event(it is a standard type, i want -// it to define track loop points, as defined by the midi standard) +//***************************************************************************** +// This is the end-of-track event. +//***************************************************************************** class tEndOfTrack : public JZEvent { public: @@ -1602,8 +1653,8 @@ } }; - - +//***************************************************************************** +//***************************************************************************** class tKeySignat : public JZEvent { public: @@ -1635,7 +1686,9 @@ } }; -// SN++ Aftertouch +//***************************************************************************** +// Aftertouch +//***************************************************************************** class tKeyPressure: public tChannelEvent { public: @@ -1689,7 +1742,9 @@ } }; -// SN++ Channel Pressure +//***************************************************************************** +// Channel Pressure +//***************************************************************************** class tChnPressure : public tChannelEvent { public: Modified: trunk/jazz/src/Synth.cpp =================================================================== --- trunk/jazz/src/Synth.cpp 2008-05-24 18:53:41 UTC (rev 561) +++ trunk/jazz/src/Synth.cpp 2008-05-24 19:03:32 UTC (rev 562) @@ -487,148 +487,176 @@ } } -int tSynthSysex::GetId(const tSysEx* s) const +int tSynthSysex::GetId(const tSysEx* pSysEx) const { - if (!s) - return SX_NONE; + if (!pSysEx) + { + return SX_NONE; + } - switch (s->mpData[0]) - { + const unsigned char* pData = pSysEx->GetData(); + switch (pData[0]) + { case 0x7e: - // GM ON ? - if (!memcmp(sxdata[SX_GM_ON], s->mpData, s->Length)) - { - return SX_GM_ON; - } - else - { - return SX_UNIV_NON_REALTIME; - } - break; + // GM ON ? + if (!memcmp(sxdata[SX_GM_ON], pData, pSysEx->GetDataLength())) + { + return SX_GM_ON; + } + else + { + return SX_UNIV_NON_REALTIME; + } + break; case 0x7f: - // GM MasterVol ? - if (!memcmp(sxdata[SX_GM_MasterVol], s->mpData, 4)) - { - return SX_GM_MasterVol; - } - else - { - return SX_UNIV_REALTIME; - } - break; + // GM MasterVol ? + if (!memcmp(sxdata[SX_GM_MasterVol], pData, 4)) + { + return SX_GM_MasterVol; + } + else + { + return SX_UNIV_REALTIME; + } + break; case 0x41: - // Roland! + //------- + // Roland + //------- - // GS DT1? - if ((s->mpData[2] == 0x42) && (s->mpData[3] == 0x12)) - { - register unsigned char a1 = s->mpData[4]; - register unsigned char a2 = s->mpData[5]; - register unsigned char a3 = s->mpData[6]; + // GS DT1? + if (pData[2] == 0x42 && pData[3] == 0x12) + { + register unsigned char a1 = pData[4]; + register unsigned char a2 = pData[5]; + register unsigned char a3 = pData[6]; - if (a1 == 0x40) - { - // MSB address 0x40: - if (a2 == 0x00) - { - // 0x40 0x00 0x?? - switch (a3) - { - case 0x7f: - return SX_GS_ON; - case 0x04: - return SX_GS_MasterVol; - case 0x06: - return SX_GS_MasterPan; - default: - break; - } - } - else if (a2 == 0x01) - { - // 0x40 0x01 0x?? - if ((a3 >= 0x30) && (a3 <= 0x36)) - // reverb settings - return SX_GS_ReverbMacro + (a3 - 0x30); - else if ((a3 >= 0x38) && (a3 <= 0x3f)) - // chorus settings - return SX_GS_ChorusMacro + (a3 - 0x38); - else if (a3 == 0x10) - return SX_GS_PartialReserve; - } - else if ((a2 & 0xf0) == 0x10) - { - // 0x40 0x1n 0x?? - switch (a3) - { - case 0x02: - return SX_GS_RxChannel; + if (a1 == 0x40) + { + // MSB address 0x40: + if (a2 == 0x00) + { + // 0x40 0x00 0x?? + switch (a3) + { + case 0x7f: + return SX_GS_ON; + case 0x04: + return SX_GS_MasterVol; + case 0x06: + return SX_GS_MasterPan; + default: + break; + } + } + else if (a2 == 0x01) + { + // 0x40 0x01 0x?? + if (a3 >= 0x30 && a3 <= 0x36) + { + // These are reverb settings. + return SX_GS_ReverbMacro + (a3 - 0x30); + } + else if (a3 >= 0x38 && a3 <= 0x3f) + { + // These are chorus settings. + return SX_GS_ChorusMacro + (a3 - 0x38); + } + else if (a3 == 0x10) + { + return SX_GS_PartialReserve; + } + } + else if ((a2 & 0xf0) == 0x10) + { + // 0x40 0x1n 0x?? + switch (a3) + { + case 0x02: + return SX_GS_RxChannel; - case 0x15: - return SX_GS_UseForRhythm; + case 0x15: + return SX_GS_UseForRhythm; - case 0x1f: - return SX_GS_CC1CtrlNo; + case 0x1f: + return SX_GS_CC1CtrlNo; - case 0x20: - return SX_GS_CC2CtrlNo; - default: - break; - } - } - else if ((a2 & 0xf0) == 0x20) - { - // 0x40 0x2n 0x?? - if (a3 <= 0x0a) - return SX_GS_ModPitch + (a3 - 0x00); - else if ((a3 >= 0x10) && (a3 <= 0x1a)) - return SX_GS_BendPitch + (a3 - 0x10); - else if ((a3 >= 0x20) && (a3 <= 0x2a)) - return SX_GS_CafPitch + (a3 - 0x20); - else if ((a3 >= 0x30) && (a3 <= 0x3a)) - return SX_GS_PafPitch + (a3 - 0x30); - else if ((a3 >= 0x40) && (a3 <= 0x4a)) - return SX_GS_CC1Pitch + (a3 - 0x40); - else if ((a3 >= 0x50) && (a3 <= 0x5a)) - return SX_GS_CC2Pitch + (a3 - 0x50); - } - } // end a1 == 0x40 - } // end GS DT1 + case 0x20: + return SX_GS_CC2CtrlNo; - if ((s->mpData[3] == 0x12) && (s->Length >= 10)) - { - return SX_ROLAND_DT1; - } - else if ((s->mpData[3] == 0x11) && (s->Length >= 12)) - { - return SX_ROLAND_RQ1; - } - else - { - return SX_ROLAND_UNKNOWN; - } + default: + break; + } + } + else if ((a2 & 0xf0) == 0x20) + { + // 0x40 0x2n 0x?? + if (a3 <= 0x0a) + { + return SX_GS_ModPitch + (a3 - 0x00); + } + else if (a3 >= 0x10 && a3 <= 0x1a) + { + return SX_GS_BendPitch + (a3 - 0x10); + } + else if (a3 >= 0x20 && a3 <= 0x2a) + { + return SX_GS_CafPitch + (a3 - 0x20); + } + else if (a3 >= 0x30 && a3 <= 0x3a) + { + return SX_GS_PafPitch + (a3 - 0x30); + } + else if (a3 >= 0x40 && a3 <= 0x4a) + { + return SX_GS_CC1Pitch + (a3 - 0x40); + } + else if (a3 >= 0x50 && a3 <= 0x5a) + { + return SX_GS_CC2Pitch + (a3 - 0x50); + } + } + } // end a1 == 0x40 + } // end GS DT1 - break; // end Roland + if (pData[3] == 0x12 && pSysEx->GetDataLength() >= 10) + { + return SX_ROLAND_DT1; + } + else if (pData[3] == 0x11 && pSysEx->GetDataLength() >= 12) + { + return SX_ROLAND_RQ1; + } + else + { + return SX_ROLAND_UNKNOWN; + } + break; + // end Roland + case 0x43: - // Yamaha! + //------- + // Yamaha + //------- + // XG Native? - if (((s->mpData[1] & 0xf0) == 0x10) && (s->mpData[2] == 0x4c)) + if (((pData[1] & 0xf0) == 0x10) && pData[2] == 0x4c) { - register unsigned char a1 = s->mpData[3]; - register unsigned char a2 = s->mpData[4]; - register unsigned char a3 = s->mpData[5]; + register unsigned char a1 = pData[3]; + register unsigned char a2 = pData[4]; + register unsigned char a3 = pData[5]; // Multipart? if (a1 == 0x08) { - if ((a3 >= 0x1d) && (a3 <= 0x28)) + if (a3 >= 0x1d && a3 <= 0x28) { return SX_XG_ModPitch + (a3 - 0x1d); } - else if ((a3 >= 0x4d) && (a3 <= 0x66)) + else if (a3 >= 0x4d && a3 <= 0x66) { return SX_XG_CafPitch + (a3 - 0x4d); } @@ -643,7 +671,7 @@ } // Effect 1? - else if ((a1 == 0x02) && (a2 == 0x01)) + else if (a1 == 0x02 && a2 == 0x01) { if (a3 == 0x00) { @@ -654,8 +682,9 @@ return SX_XG_ChorusMacro; } } + // Multi EQ? - else if ((a1 == 0x02) && (a2 == 0x40)) + else if (a1 == 0x02 && a2 == 0x40) { if (a3 == 0x00) { @@ -664,17 +693,17 @@ } // XG system on? - else if ((a1 == 0x00) && (a2 == 0x00) && (a3 == 0x7e)) + else if (a1 == 0x00 && a2 == 0x00 && a3 == 0x7e) { return SX_XG_ON; } } - if (s->mpData[2] == 0x4c) + if (pData[2] == 0x4c) { return SX_XG_NATIVE; } - else if (s->mpData[2] == 0x49) + else if (pData[2] == 0x49) { return SX_MU80_NATIVE; } @@ -683,58 +712,64 @@ return SX_YAMAHA_UNKNOWN; } - break; // end Yamaha + break; + // end Yamaha default: break; - } + } - // Not recognized - return SX_NONE; + // Not recognized + return SX_NONE; } -unsigned char* tSynthSysex::GetValPtr(const tSysEx* s) const +const unsigned char* tSynthSysex::GetValPtr(const tSysEx* pSysEx) const { - if (!s) + if (!pSysEx) { return 0; } - switch (s->mpData[0]) + const unsigned char* pData = pSysEx->GetData(); + switch (pData[0]) { case 0x7f: // GM MasterVol? - if (!memcmp(sxdata[SX_GM_MasterVol], s->mpData,4)) + if (!memcmp(sxdata[SX_GM_MasterVol], pData, 4)) { - return &s->mpData[4]; + return &pData[4]; } break; case 0x41: - // Roland! + //------- + // Roland + //------- + // GS DT1? - if ((s->mpData[2] == 0x42) && (s->mpData[3] == 0x12) && (s->Length >= 10)) + if (pData[2] == 0x42 && pData[3] == 0x12 && pSysEx->GetDataLength() >= 10) { - return &s->mpData[7]; + return &pData[7]; } // other DT1 or RQ1 ? else if ( - ((s->mpData[3] == 0x12) && (s->Length >= 10)) || - ((s->mpData[3] == 0x11) && (s->Length >= 12))) + (pData[3] == 0x12 && pSysEx->GetDataLength() >= 10) || + (pData[3] == 0x11 && pSysEx->GetDataLength() >= 12)) { - return &s->mpData[7]; + return &pData[7]; } break; case 0x43: // Yamaha! // XG Native? - if (((s->mpData[1] & 0xf0) == 0x10) && (s->mpData[2] == 0x4c)) + if (((pData[1] & 0xf0) == 0x10) && pData[2] == 0x4c) { - return &s->mpData[6]; + return &pData[6]; } break; + default: break; } @@ -743,73 +778,66 @@ return 0; } -unsigned char * tSynthSysex::GetChaPtr(const tSysEx* s) +//----------------------------------------------------------------------------- +// Description: +// Return a pointer to the byte with the channel (if any). +//----------------------------------------------------------------------------- +const unsigned char* tSynthSysex::GetChaPtr(const tSysEx* pSysEx) { - // Get the byte where the channel number is (if any) + if (!pSysEx) + { + return 0; + } - if (!s) - { - return 0; - } - - switch (s->mpData[0]) - { + const unsigned char* pData = pSysEx->GetData(); + switch (pData[0]) + { case 0x41: - // Roland! - // GS DT1 + address 0x40? - if ( - (s->mpData[2] == 0x42) && - (s->mpData[3] == 0x12) && - (s->mpData[4] == 0x40)) - { - if ( - ((s->mpData[5] & 0xf0) == 0x10) || - ((s->mpData[5] & 0xf0) == 0x20)) - { - return &s->mpData[5]; - } - } - break; + //------- + // Roland + //------- + // GS DT1 + address 0x40? + if (pData[2] == 0x42 && pData[3] == 0x12 && pData[4] == 0x40) + { + if ((pData[5] & 0xf0) == 0x10 || (pData[5] & 0xf0) == 0x20) + { + return &pData[5]; + } + } + break; + case 0x43: - // Yamaha! - // XG Native multipart? - if ( - ((s->mpData[1] & 0xf0) == 0x10) && - (s->mpData[2] == 0x4c) && - (s->mpData[3] == 0x08)) - { - return &s->mpData[4]; - } - break; + //------- + // Yamaha + //------- + + // XG Native multipart? + if ((pData[1] & 0xf0) == 0x10 && pData[2] == 0x4c && pData[3] == 0x08) + { + return &pData[4]; + } + break; default: - break; - } + break; + } - // Not recognized - return 0; + // Not recognized. + return 0; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tSynthSysex::FixCheckSum(tSysEx* s) +void tSynthSysex::FixCheckSum(tSysEx* pSysEx) { + const unsigned char* pData = pSysEx->GetData(); if ( - (s->mpData[0] == 0x41) && - (((s->mpData[3] == 0x12) && (s->Length >= 10)) || - ((s->mpData[3] == 0x11) && (s->Length >= 12)))) + pData[0] == 0x41 && + ((pData[3] == 0x12 && pSysEx->GetDataLength() >= 10) || + (pData[3] == 0x11 && pSysEx->GetDataLength() >= 12))) { - // Roland RQ1 or DT1 - int len = s->Length; - unsigned char *sx = s->mpData; - unsigned char sum = 0x00; - - for (int i = 4; i < (len-2); i++) - { - sum += sx[i]; - } - sx[len - 2] = (0x80 - (sum & 0x7f)) & 0x7f; - sx[len-1] = 0xf7; + // The synthesizer is a Roland RQ1 or DT1. + pSysEx->FixCheckSum(); } } @@ -852,7 +880,7 @@ int len = sxlen[id] + datalen - 1; unsigned char* sx = new unsigned char[len]; memcpy(sx, sxdata[id], sxlen[id]); - tSysEx* s = 0; + tSysEx* pSysEx = 0; if (id == SX_GM_MasterVol) { @@ -862,7 +890,7 @@ else sx[4] = 0; sx[5] = val[0]; // MSB - s = new tSysEx(clk, sx, len); + pSysEx = new tSysEx(clk, sx, len); } else if ((id > SX_GS_ON) && (id < SX_XG_ON)) { @@ -880,7 +908,7 @@ sum += sx[i]; sx[len - 2] = (0x80 - (sum & 0x7f)) & 0x7f; sx[len-1] = 0xf7; - s = new tSysEx(clk, sx, len); + pSysEx = new tSysEx(clk, sx, len); } else if (id > SX_XG_ON) { @@ -895,11 +923,11 @@ sx[4] = channel - 1; } sx[len-1] = 0xf7; - s = new tSysEx(clk, sx, len); + pSysEx = new tSysEx(clk, sx, len); } delete sx; - return s; + return pSysEx; } Modified: trunk/jazz/src/Synth.h =================================================================== --- trunk/jazz/src/Synth.h 2008-05-24 18:53:41 UTC (rev 561) +++ trunk/jazz/src/Synth.h 2008-05-24 19:03:32 UTC (rev 562) @@ -245,10 +245,11 @@ int GetId(const tSysEx* s) const; // Get pointer to the data value (if any) - unsigned char* GetValPtr(const tSysEx* s) const; + const unsigned char* GetValPtr(const tSysEx* pSysEx) const; - // Get pointer to the byte with the channel (if any) - unsigned char* GetChaPtr(const tSysEx* s); + // Description: + // Return a pointer to the byte with the channel (if any). + const unsigned char* GetChaPtr(const tSysEx* pSysEx); // Fix checksum byte (if any) void FixCheckSum( tSysEx *s ); @@ -309,14 +310,14 @@ return Sysex.GetId( s ); } - virtual unsigned char * GetSysexValPtr( tSysEx *s ) const + virtual const unsigned char* GetSysexValPtr(tSysEx* pSysEx) const { - return Sysex.GetValPtr( s ); + return Sysex.GetValPtr(pSysEx); } - virtual unsigned char * GetSysexChaPtr( tSysEx *s ) + virtual const unsigned char* GetSysexChaPtr(tSysEx* pSysEx) { - return Sysex.GetChaPtr( s ); + return Sysex.GetChaPtr(pSysEx); } virtual void FixSysexCheckSum( tSysEx *s ) Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-05-24 18:53:41 UTC (rev 561) +++ trunk/jazz/src/Track.cpp 2008-05-24 19:03:32 UTC (rev 562) @@ -90,9 +90,10 @@ static double framesPerSecond[] = { 24.0, 25.0, 30.0, 30.0 }; -tMtcTime::tMtcTime(tMtcOffset *s) +tMtcTime::tMtcTime(tMtcOffset* pMtcOffset) { - type = (tMtcType) ((s->mpData[0] & 0x60) >> 5); + const unsigned char* pData = pMtcOffset->GetData(); + type = (tMtcType) ((pData[0] & 0x60) >> 5); if (type < Mtc24) { type = Mtc24; @@ -101,10 +102,10 @@ { type = Mtc30Ndf; } - hour = s->mpData[0] & 0x1f; - min = s->mpData[1]; - sec = s->mpData[2]; - fm = s->mpData[3]; + hour = pData[0] & 0x1f; + min = pData[1]; + sec = pData[2]; + fm = pData[3]; } tMtcTime::tMtcTime(int millisec, tMtcType t) @@ -567,7 +568,7 @@ tEventArray::tEventArray() : tSimpleEventArray(), - mName(0), + mpName(0), Copyright(0), mPatch(0), Speed(0), @@ -599,8 +600,8 @@ tSimpleEventArray::Clear(); -// delete mName; - mName = 0; +// delete mpName; + mpName = 0; Copyright = 0; @@ -738,8 +739,8 @@ Sort(); // moves all killed events to the end of array // clear track defaults -// delete mName; - mName = 0; +// delete mpName; + mpName = 0; Copyright = 0; @@ -828,9 +829,9 @@ continue; } - if (!mName) + if (!mpName) { - mName = e->IsTrackName(); + mpName = e->IsTrackName(); } if (!Copyright) @@ -1774,17 +1775,17 @@ else if ((s = e->IsSysEx()) != 0) { // Check for sysex that contains channel number - unsigned char *chaptr = gpSynth->GetSysexChaPtr(s); - if (chaptr) + const unsigned char* pChannel = gpSynth->GetSysexChaPtr(s); + if (pChannel) { if (gpSynth->IsXG()) { - *chaptr = trk->Channel - 1; + *pChannel = trk->Channel - 1; } else { - *chaptr &= 0xf0; - *chaptr |= sysex_channel(trk->Channel); + *pChannel &= 0xf0; + *pChannel |= sysex_channel(trk->Channel); } s = (tSysEx *) e->Copy(); @@ -2114,7 +2115,7 @@ { if (Copyright) { - return (const char *)Copyright->mpData; + return (const char *)Copyright->GetData(); } return ""; } @@ -2143,9 +2144,9 @@ const char* JZTrack::GetName() { - if (mName) + if (mpName) { - return (const char*)mName->mpData; + return (const char*)mpName->GetData(); } return ""; } @@ -2154,9 +2155,9 @@ void JZTrack::SetName(const char* pTrackName) { - if (mName) + if (mpName) { - Kill(mName); + Kill(mpName); } if (strlen(pTrackName)) { @@ -2713,11 +2714,12 @@ int JZTrack::GetModulationSysex(int msp) { - unsigned char *valp = gpSynth->GetSysexValPtr(ModulationSettings[msp]); + const unsigned char* pValue = + gpSynth->GetSysexValPtr(ModulationSettings[msp]); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -2745,11 +2747,11 @@ int JZTrack::GetBenderSysex(int bsp) { - unsigned char *valp = gpSynth->GetSysexValPtr(BenderSettings[bsp]); + const unsigned char* pValue = gpSynth->GetSysexValPtr(BenderSettings[bsp]); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -2777,11 +2779,11 @@ int JZTrack::GetCAfSysex(int csp) { - unsigned char *valp = gpSynth->GetSysexValPtr(CAfSettings[csp]); + const unsigned char* pValue = gpSynth->GetSysexValPtr(CAfSettings[csp]); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -2809,11 +2811,11 @@ int JZTrack::GetPAfSysex(int psp) { - unsigned char *valp = gpSynth->GetSysexValPtr(PAfSettings[psp]); + const unsigned char* pValue = gpSynth->GetSysexValPtr(PAfSettings[psp]); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -2841,11 +2843,11 @@ int JZTrack::GetCC1Sysex(int csp) { - unsigned char *valp = gpSynth->GetSysexValPtr(CC1Settings[csp]); + const unsigned char* pValue = gpSynth->GetSysexValPtr(CC1Settings[csp]); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -2873,11 +2875,11 @@ int JZTrack::GetCC2Sysex(int csp) { - unsigned char *valp = gpSynth->GetSysexValPtr(CC2Settings[csp]); + const unsigned char* pValue = gpSynth->GetSysexValPtr(CC2Settings[csp]); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -2903,11 +2905,11 @@ int JZTrack::GetCC1ControllerNr() { - unsigned char *valp = gpSynth->GetSysexValPtr(CC1ControllerNr); + const unsigned char* pValue = gpSynth->GetSysexValPtr(CC1ControllerNr); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -2935,11 +2937,11 @@ int JZTrack::GetCC2ControllerNr() { - unsigned char *valp = gpSynth->GetSysexValPtr(CC2ControllerNr); + const unsigned char* pValue = gpSynth->GetSysexValPtr(CC2ControllerNr); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -2967,15 +2969,15 @@ int JZTrack::GetReverbType(int lsb) { - unsigned char *valp = gpSynth->GetSysexValPtr(ReverbType); + const unsigned char* pValue = gpSynth->GetSysexValPtr(ReverbType); - if (valp) + if (pValue) { if (lsb) { - ++valp; + ++pValue; } - return *valp + 1; + return *pValue + 1; } return 0; @@ -3007,16 +3009,16 @@ int JZTrack::GetChorusType(int lsb) { - unsigned char *valp = gpSynth->GetSysexValPtr(ChorusType); + const unsigned char *pValue = gpSynth->GetSysexValPtr(ChorusType); - if (valp) + if (pValue) { if (lsb) { - ++valp; + ++pValue; } - return *valp + 1; + return *pValue + 1; } return 0; @@ -3048,11 +3050,11 @@ int JZTrack::GetEqualizerType() { - unsigned char *valp = gpSynth->GetSysexValPtr(EqualizerType); + const unsigned char* pValue = gpSynth->GetSysexValPtr(EqualizerType); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -3081,11 +3083,11 @@ int JZTrack::GetRevSysex(int rsp) { - unsigned char *valp = gpSynth->GetSysexValPtr(ReverbSettings[rsp]); + const unsigned char* pValue = gpSynth->GetSysexValPtr(ReverbSettings[rsp]); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -3117,11 +3119,11 @@ int JZTrack::GetChoSysex(int csp) { - unsigned char *valp = gpSynth->GetSysexValPtr(ChorusSettings[csp]); + const unsigned char* pValue = gpSynth->GetSysexValPtr(ChorusSettings[csp]); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -3154,11 +3156,11 @@ int JZTrack::GetPartRsrv(int chan) { - unsigned char *valp = gpSynth->GetSysexValPtr(PartialReserve); + const unsigned char* pValue = gpSynth->GetSysexValPtr(PartialReserve); - if (valp) + if (pValue) { - return *(valp + sysex_channel(chan)) + 1; + return *(pValue + sysex_channel(chan)) + 1; } return 0; @@ -3187,17 +3189,17 @@ int JZTrack::GetMasterVol() { - unsigned char *valp = gpSynth->GetSysexValPtr(MasterVol); + const unsigned char* pValue = gpSynth->GetSysexValPtr(MasterVol); - if (valp) + if (pValue) { if (gpSynth->GetSysexId(MasterVol) == SX_GM_MasterVol) { // first data byte is lsb; get msb instead! - ++valp; + ++pValue; } - return *valp + 1; + return *pValue + 1; } return 0; @@ -3226,11 +3228,11 @@ int JZTrack::GetMasterPan() { - unsigned char *valp = gpSynth->GetSysexValPtr(MasterPan); + const unsigned char* pValue = gpSynth->GetSysexValPtr(MasterPan); - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; @@ -3258,22 +3260,22 @@ int JZTrack::GetModeSysex(int param) { - unsigned char *valp = 0; + const unsigned char* pValue = 0; switch (param) { case mspRxChannel: - valp = gpSynth->GetSysexValPtr(RxChannel); + pValue = gpSynth->GetSysexValPtr(RxChannel); break; case mspUseForRhythm: - valp = gpSynth->GetSysexValPtr(UseForRhythm); + pValue = gpSynth->GetSysexValPtr(UseForRhythm); break; } - if (valp) + if (pValue) { - return *valp + 1; + return *pValue + 1; } return 0; Modified: trunk/jazz/src/Track.h =================================================================== --- trunk/jazz/src/Track.h 2008-05-24 18:53:41 UTC (rev 561) +++ trunk/jazz/src/Track.h 2008-05-24 19:03:32 UTC (rev 562) @@ -451,7 +451,7 @@ public: - tTrackName* mName; + tTrackName* mpName; tCopyright* Copyright; tProgram* mPatch; tSetTempo* Speed; Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-24 18:53:41 UTC (rev 561) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-24 19:03:32 UTC (rev 562) @@ -428,7 +428,7 @@ state->sysex_found = TRUE; tWinSysexBuffer *buf = state->osx_buffers->AllocBuffer(); - buf->PrepareOut(state->hout, sx->mpData, sx->Length - 1); + buf->PrepareOut(state->hout, sx->GetData(), sx->GetLength() - 1); state->play_buffer.put(SYSEX_EVENT, time); state->play_buffer.put((DWORD)buf, time); return 0; @@ -486,13 +486,13 @@ else if (pEvent->GetStat() == StatSysEx) { tSysEx *s = pEvent->IsSysEx(); - if (s->Length + 1 < maxSysLen) + if (s->GetDataLength() + 1 < maxSysLen) { pSysBuf[0] = 0xf0; - memcpy(pSysBuf + 1, s->mpData, s->Length); + memcpy(pSysBuf + 1, s->GetData(), s->GetDataLength()); pSysHdr->lpData = (LPSTR)pSysBuf; - pSysHdr->dwBufferLength = s->Length + 1; + pSysHdr->dwBufferLength = s->GetDataLength() + 1; pSysHdr->dwUser = 0; if (midiOutPrepareHeader(state->hout, pSysHdr, sizeof(MIDIHDR)) == 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-24 22:00:00
|
Revision: 564 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=564&view=rev Author: pstieber Date: 2008-05-24 14:59:59 -0700 (Sat, 24 May 2008) Log Message: ----------- Encapsulated the members of tKeyPressure. Modified Paths: -------------- trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/Command.cpp trunk/jazz/src/ControlEdit.cpp trunk/jazz/src/Events.h trunk/jazz/src/Filter.h trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/Player.cpp trunk/jazz/src/StandardFile.cpp trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-05-24 19:10:41 UTC (rev 563) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-05-24 21:59:59 UTC (rev 564) @@ -443,11 +443,11 @@ case StatKeyPressure: { - tKeyPressure *k = pEvent->IsKeyPressure(); + tKeyPressure* pKeyPressure = pEvent->IsKeyPressure(); set_event_header(&ev, pEvent->GetClock(), SND_SEQ_EVENT_KEYPRESS); - ev.data.note.channel = k->GetChannel(); - ev.data.note.note = k->Key; - ev.data.note.velocity = k->Value; + ev.data.note.channel = pKeyPressure->GetChannel(); + ev.data.note.note = pKeyPressure->GetKey(); + ev.data.note.velocity = pKeyPressure->GetPressureValue(); rc = write(&ev, now); } break; Modified: trunk/jazz/src/Command.cpp =================================================================== --- trunk/jazz/src/Command.cpp 2008-05-24 19:10:41 UTC (rev 563) +++ trunk/jazz/src/Command.cpp 2008-05-24 21:59:59 UTC (rev 564) @@ -408,22 +408,23 @@ pTrack->Kill(pEvent); pTrack->Put(pKeyOn); } -// SN++ Aftertouch - tKeyPressure *a; + + // After touch. if (pEvent->IsKeyPressure()) { - a = (tKeyPressure *)pEvent->Copy(); + tKeyPressure* pKeyPressure = (tKeyPressure *)pEvent->Copy(); if (FitIntoScale) { - a->Key += Notes; - a->Key = Scale.FitInto(a->Key); + pKeyPressure->SetKey(pKeyPressure->GetKey() + Notes); + pKeyPressure->SetKey(Scale.FitInto(pKeyPressure->GetKey())); } else if (Notes) - a->Key = Scale.Transpose(a->Key, Notes); + { + pKeyPressure->SetKey(Scale.Transpose(pKeyPressure->GetKey(), Notes)); + } pTrack->Kill(pEvent); - pTrack->Put(a); + pTrack->Put(pKeyPressure); } -// } // ************************************************************************ Modified: trunk/jazz/src/ControlEdit.cpp =================================================================== --- trunk/jazz/src/ControlEdit.cpp 2008-05-24 19:10:41 UTC (rev 563) +++ trunk/jazz/src/ControlEdit.cpp 2008-05-24 21:59:59 UTC (rev 564) @@ -631,9 +631,10 @@ int tPolyAfterEdit::GetValue(JZEvent* pEvent) { - if (pEvent->IsKeyPressure()) + tKeyPressure* pKeyPressure = pEvent->IsKeyPressure(); + if (pKeyPressure) { - return pEvent->IsKeyPressure()->Value; + return pKeyPressure->GetPressureValue(); } return -1; } @@ -666,7 +667,6 @@ from_clk = from_clock; to_clk = to_clock; } - tKeyPressure *k; tKeyOn* pKeyOn; if (!ctrlmode) @@ -681,10 +681,10 @@ !mpPianoWindow->mpSnapSel->IsSelected() || mpPianoWindow->GetFilter()->IsSelected(pEvent)) { - k = pEvent->IsKeyPressure(); - if (k) + tKeyPressure* pKeyPressure = pEvent->IsKeyPressure(); + if (pKeyPressure) { - track->Kill(k); + track->Kill(pKeyPressure); } } pEvent = iter.Next(); @@ -693,7 +693,7 @@ long key_end(-1), key_clk(-1); int key_val = -1; int key_cha(-1); - JZEvent *after; + tKeyPressure* pKeyPressure; pEvent = iter.Range(from_clk, to_clk); while (pEvent) { @@ -720,8 +720,8 @@ // und der Wert groesser als 0 ist. if (array[i] > 0 && array[i] != temp) { - after = new tKeyPressure(iclk, key_cha, key_val, array[i]); - track->Put(after); + pKeyPressure = new tKeyPressure(iclk, key_cha, key_val, array[i]); + track->Put(pKeyPressure); temp = array[i]; } } @@ -747,10 +747,12 @@ { if (pEvent->IsKeyPressure()) { - if (Clock2Val(pEvent->GetClock()) != pEvent->IsKeyPressure()->Value) + if ( + Clock2Val(pEvent->GetClock()) != + pEvent->IsKeyPressure()->GetPressureValue()) { pKeyPressureCopy = pEvent->Copy()->IsKeyPressure(); - pKeyPressureCopy->Value = Clock2Val(pEvent->GetClock()); + pKeyPressureCopy->SetPressureValue(Clock2Val(pEvent->GetClock())); track->Kill(pEvent); track->Put(pKeyPressureCopy); } Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-05-24 19:10:41 UTC (rev 563) +++ trunk/jazz/src/Events.h 2008-05-24 21:59:59 UTC (rev 564) @@ -1692,23 +1692,22 @@ class tKeyPressure: public tChannelEvent { public: - short Value; - short Key; tKeyPressure( int Clock, unsigned short Channel, - unsigned char key, - unsigned char val) - : tChannelEvent(Clock, StatKeyPressure, Channel) + unsigned char Key, + unsigned char Value) + : tChannelEvent(Clock, StatKeyPressure, Channel), + mKey(Key), + mValue(Value) { - Value = val; - Key = key; } virtual int Write(JZWriteBase &io) { - edb(); return io.Write(this, Key, Value); + edb(); + return io.Write(this, mKey, mValue); } virtual tKeyPressure* IsKeyPressure() @@ -1726,20 +1725,45 @@ virtual int GetValue() const { edb(); - return Value; + return mValue; } virtual int GetPitch() const { edb(); - return Key; + return mKey; } - virtual void SetPitch(int p) + virtual void SetPitch(int Pitch) { edb(); - Key = p; + mKey = Pitch; } + + unsigned char GetKey() const + { + return mKey; + } + + void SetKey(unsigned char Key) + { + mKey = Key; + } + + short GetPressureValue() const + { + return mValue; + } + + void SetPressureValue(short Value) + { + mValue = Value; + } + + private: + + short mKey; + short mValue; }; //***************************************************************************** Modified: trunk/jazz/src/Filter.h =================================================================== --- trunk/jazz/src/Filter.h 2008-05-24 19:10:41 UTC (rev 563) +++ trunk/jazz/src/Filter.h 2008-05-24 21:59:59 UTC (rev 564) @@ -89,7 +89,7 @@ // SN++ Aftertouch gehoert eigendlich zu KeyOn Events. if (pEvent->GetStat() == StatKeyPressure) { - int aval = pEvent->IsKeyPressure()->Key; + int aval = pEvent->IsKeyPressure()->GetKey(); return FltEvents[i].Selected && FltEvents[i].FromValue <= aval && Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2008-05-24 19:10:41 UTC (rev 563) +++ trunk/jazz/src/PianoWindow.cpp 2008-05-24 21:59:59 UTC (rev 564) @@ -281,18 +281,23 @@ { int key, channel; tEventIterator iter(Win->GetTrack()); - tKeyPressure *a; key = Copy->GetKey(); channel = Copy->GetChannel(); + + tKeyPressure* pKeyPressure; + JZEvent* pEvent = iter.Range( Copy->GetClock() + Copy->GetEventLength(), Copy->GetClock() + mpKeyOn->GetEventLength()); + while (pEvent) { - a = pEvent->IsKeyPressure(); - if (a) + pKeyPressure = pEvent->IsKeyPressure(); + if (pKeyPressure) { - if (a->Key == key && a->GetChannel() == channel) + if ( + pKeyPressure->GetKey() == key && + pKeyPressure->GetChannel() == channel) { Win->KillTrackEvent(pEvent); } @@ -2404,7 +2409,6 @@ { int key,channel; tEventIterator iter(pTrack); - tKeyPressure *a; tKeyOn* pKeyOn = pEvent->IsKeyOn(); if (!pKeyOn) { @@ -2416,15 +2420,19 @@ } key = pKeyOn->GetKey(); channel = pKeyOn->GetChannel(); + + tKeyPressure* pKeyPressure; pEvent = iter.Range( pKeyOn->GetClock() + 1, pKeyOn->GetClock() + pKeyOn->GetEventLength()); while (pEvent) { - a = pEvent->IsKeyPressure(); - if (a) + pKeyPressure = pEvent->IsKeyPressure(); + if (pKeyPressure) { - if (a->Key == key && a->GetChannel() == channel) + if ( + pKeyPressure->GetKey() == key && + pKeyPressure->GetChannel() == channel) { pTrack->Kill(pEvent); } @@ -2439,7 +2447,6 @@ { int key,channel; tEventIterator iter(pTrack); - tKeyPressure *a; tKeyOn* pKeyOn = pEvent->IsKeyOn(); if (!pKeyOn) { @@ -2452,16 +2459,20 @@ } key = pKeyOn->GetKey(); + tKeyPressure* pKeyPressure; + pEvent = iter.Range( pKeyOn->GetClock() + 1, pKeyOn->GetClock() + pKeyOn->GetEventLength()); while (pEvent) { - a = pEvent->IsKeyPressure(); - if (a) + pKeyPressure = pEvent->IsKeyPressure(); + if (pKeyPressure) { - if (a->Key == key && a->GetChannel() == channel) + if ( + pKeyPressure->GetKey() == key && + pKeyPressure->GetChannel() == channel) { mPasteBuffer.Put(pEvent->Copy()); } Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-05-24 19:10:41 UTC (rev 563) +++ trunk/jazz/src/Player.cpp 2008-05-24 21:59:59 UTC (rev 564) @@ -1668,8 +1668,14 @@ // SN++ Aftertouch case StatKeyPressure: { - tKeyPressure *k = pEvent->IsKeyPressure(); - SEQ_KEY_PRESSURE(mididev, k->GetChannel(), k->Key, k->Value); + tKeyPressure* pKeyPressure = pEvent->IsKeyPressure(); + + SEQ_KEY_PRESSURE( + mididev, + pKeyPressure->GetChannel(), + pKeyPressure->GetKey(), + pKeyPressure->GetPressureValue()); + if (now) { seqbuf_flush_last_event(); Modified: trunk/jazz/src/StandardFile.cpp =================================================================== --- trunk/jazz/src/StandardFile.cpp 2008-05-24 19:10:41 UTC (rev 563) +++ trunk/jazz/src/StandardFile.cpp 2008-05-24 21:59:59 UTC (rev 564) @@ -476,7 +476,6 @@ return pEvent; case StatKeyPressure: -// SN++ Aftertouch pEvent = new tKeyPressure(Clock, Channel, cp[0], cp[1]); cp += 2; return pEvent; Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-24 19:10:41 UTC (rev 563) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-24 21:59:59 UTC (rev 564) @@ -310,10 +310,10 @@ case StatKeyPressure: { - tKeyPressure *k = pEvent->IsKeyPressure(); - u.c[0] = 0xA0 | k->GetChannel(); - u.c[1] = k->Key; - u.c[2] = k->Value; + tKeyPressure* pKeyPressure = pEvent->IsKeyPressure(); + u.c[0] = 0xA0 | pKeyPressure->GetChannel(); + u.c[1] = pKeyPressure->GetKey(); + u.c[2] = pKeyPressure->GetPressureValue(); } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-26 23:38:38
|
Revision: 568 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=568&view=rev Author: pstieber Date: 2008-05-26 16:38:36 -0700 (Mon, 26 May 2008) Log Message: ----------- Added a portmidi player. Added Paths: ----------- trunk/jazz/src/PortMidiPlayer.cpp trunk/jazz/src/PortMidiPlayer.h Added: trunk/jazz/src/PortMidiPlayer.cpp =================================================================== --- trunk/jazz/src/PortMidiPlayer.cpp (rev 0) +++ trunk/jazz/src/PortMidiPlayer.cpp 2008-05-26 23:38:36 UTC (rev 568) @@ -0,0 +1,414 @@ +#include "WxWidgets.h" + +#include "PortMidiPlayer.h" +#include "TrackWindow.h" +#include "Song.h" +#include "Globals.h" + +JZPortMidiPlayer::JZPortMidiPlayer(JZSong* pSong) + : JZPlayer(pSong), + mInputDevices(), + mOutputDevices(), + mpStream(0), + mInitialized(false), + mStartTime(0), + mStartClock(0), + mTicksPerMinute(100), + mInputDevice(), + mOutputDevice(), + mInDev(-1), + mOutDev(-1) +{ + InitPM(); + mInDev = Pm_GetDefaultOutputDeviceID(); + mOutDev = Pm_GetDefaultOutputDeviceID(); + TermPM(); + + Pt_Start(1, 0, 0); + +// mOutputQueue = Pm_QueueCreate(1024, sizeof(PmEvent)); +} + +JZPortMidiPlayer::~JZPortMidiPlayer() +{ +// Pm_QueueDestroy(mOutputQueue); + TermPM(); +} + +int +JZPortMidiPlayer::Installed() +{ + return true; +} + +wxString +JZPortMidiPlayer::GetInputDeviceName() +{ + return mInputDevice; +} + +wxString +JZPortMidiPlayer::GetOutputDeviceName() +{ + return mOutputDevice; +} + + +void +JZPortMidiPlayer::SetInputDevice(const wxString & name) +{ + bool term = InitPM(); + PmDeviceID id = FindDevice(name, true); + + if (id != pmNoDevice) + { + mInputDevice = name; + } + + if (term) + { + TermPM(); + } +} + +void +JZPortMidiPlayer::SetOutputDevice(const wxString& name) +{ + bool term = InitPM(); + PmDeviceID id = FindDevice(name, false); + + if (id != pmNoDevice) + { + mOutputDevice = name; + } + + if (term) + { + TermPM(); + } +} + +int +JZPortMidiPlayer::SupportsMultipleDevices() +{ + return true; +} + +tDeviceList& +JZPortMidiPlayer::GetOutputDevices() +{ + bool term = InitPM(); + int cnt; + + cnt = Pm_CountDevices(); + + mOutputDevices.Clear(); + + for (int i = 0; i < cnt; i++) + { + const PmDeviceInfo *di = Pm_GetDeviceInfo(i); + + if (di && di->output) + { + wxString name = + wxString(di->interf, wxConvISO8859_1) + + wxT(", ") + + wxString(di->name, wxConvISO8859_1); + mOutputDevices.Add(name); + } + } + + if (term) + { + TermPM(); + } + + return mOutputDevices; +} + +tDeviceList& +JZPortMidiPlayer::GetInputDevices() +{ + bool term = InitPM(); + int cnt; + + cnt = Pm_CountDevices(); + + mInputDevices.Clear(); + + for (int i = 0; i < cnt; i++) + { + const PmDeviceInfo *di = Pm_GetDeviceInfo(i); + + if (di && di->input) + { + wxString name = + wxString(di->interf, wxConvISO8859_1) + + wxT(", ") + + wxString(di->name, wxConvISO8859_1); + mInputDevices.Add(name); + } + } + + if (term) + { + TermPM(); + } + + return mInputDevices; +} + +PmDeviceID +JZPortMidiPlayer::FindDevice(const wxString & name, bool input) +{ + int cnt = Pm_CountDevices(); + + for (int i = 0; i < cnt; i++) + { + const PmDeviceInfo *di = Pm_GetDeviceInfo(i); + + if (di && (input ? di->input : di->output)) + { + wxString n = + wxString(di->interf, wxConvISO8859_1) + + wxT(", ") + + wxString(di->name, wxConvISO8859_1); + + if (name == n) + { + return i; + } + } + } + + return pmNoDevice; +} + +int +JZPortMidiPlayer::Clock2Time(int clock) +{ + if (clock < mStartClock) + { + return mStartTime; + } + + return (int)((double)(clock - mStartClock) * 60000.0 / (double) mTicksPerMinute + mStartTime); +} + +int +JZPortMidiPlayer::Time2Clock(int time) +{ + if (time < mStartTime) + { + return mStartClock; + } + + return (int)((double)(time - mStartTime) * (double) mTicksPerMinute / 60000.0 + mStartClock); +} + +void +JZPortMidiPlayer::SetTempo(int bpm, int clock) +{ + int t1 = Clock2Time(clock); + mTicksPerMinute = bpm * Song->GetTicksPerQuarter(); + int t2 = Clock2Time(clock); + mStartTime += (t1 - t2); +} + +void +JZPortMidiPlayer::OutBreak() +{ +} + +int +JZPortMidiPlayer::OutEvent(JZEvent* pEvent, int now) +{ + PmError rc = pmNoError; + PmTimestamp t = (now ? 0 : pEvent->GetClock()); + + t = Clock2Time(t); + +#define WSHORT(a, b) \ + rc = Pm_WriteShort(mpStream, t, Pm_Message(pEvent->GetStat() | k->GetChannel(), a, b)) + + switch (pEvent->GetStat()) + { + case StatKeyOn: + { + tKeyOn *k = pEvent->IsKeyOn(); + + WSHORT(k->GetKey(), k->GetVelocity()); + } + break; + + case StatKeyOff: + { + tKeyOff *k = pEvent->IsKeyOff(); + + WSHORT(k->GetKey(), k->GetOffVelocity()); + } + break; + + case StatProgram: + { + tProgram *k = pEvent->IsProgram(); + + WSHORT(k->GetProgram(), 0); + } + break; + + case StatKeyPressure: + { + tKeyPressure *k = pEvent->IsKeyPressure(); + + WSHORT(k->GetKey(), k->GetValue()); + } + break; + + case StatChnPressure: + { + tChnPressure *k = pEvent->IsChnPressure(); + + WSHORT(k->GetValue(), 0); + } + break; + + case StatControl: + { + tControl *k = pEvent->IsControl(); + + WSHORT(k->GetControl(), k->GetValue()); + } + break; + + case StatPitch: + { + tPitch *k = pEvent->IsPitch(); + + WSHORT(k->GetValue(), 0); + } + break; + + case StatSetTempo: + { + tSetTempo *k = pEvent->IsSetTempo(); + if (k->GetClock() > 0) + { + SetTempo(k->GetBPM(), k->GetClock()); + } + } + break; + + case StatSysEx: + { + tSysEx *s = pEvent->IsSysEx(); + + unsigned char *buf = new unsigned char[s->GetLength() + 2]; + + buf[0] = 0xF0; + memcpy(&buf[1], s->GetData(), s->GetLength()); + buf[s->GetLength() + 2] = 0xf7; + rc = Pm_WriteSysEx(mpStream, t, buf); + + delete[] buf; + } + break; + + default: + break; + } + + return rc != pmNoError; +} + +int +JZPortMidiPlayer::OutEvent(JZEvent* pEvent) +{ + return OutEvent(pEvent, 0); +} + +void +JZPortMidiPlayer::OutNow(JZEvent*pEvent) +{ + OutEvent(pEvent, 1); +} + +void +JZPortMidiPlayer::StartPlay(int clock, int loopClock, int cont) +{ + bool term = InitPM(); + PmDeviceID id = FindDevice(mOutputDevice, false); + + if (id == pmNoDevice) + { + if (term) + { + TermPM(); + } + + return; + } + + printf("rc = %d %d\n", Pm_OpenOutput(&mpStream, id, NULL, 0, NULL, NULL, 100), id); + + mStartTime = Pt_Time() + 500; + mStartClock = clock; + mTicksPerMinute = Song->GetTicksPerQuarter() * Song->Speed(); + + JZPlayer::StartPlay(clock, loopClock, cont); +} + +void +JZPortMidiPlayer::StopPlay() +{ + JZPlayer::StopPlay(); + + if (mpStream) + { + Pm_Abort(mpStream); + Pm_Close(mpStream); + mpStream = NULL; + } + + TermPM(); +} + +long +JZPortMidiPlayer::GetRealTimeClock() +{ + long t = Pt_Time(); + + gpTrackWindow->NewPlayPosition(PlayLoop->Ext2IntClock(Time2Clock(t) / 48 * 48)); + + return Time2Clock(t); +} + +bool +JZPortMidiPlayer::InitPM() +{ + if (mInitialized) + { + return false; + } + + Pm_Initialize(); + + mInitialized = true; + + return true; +} + +bool +JZPortMidiPlayer::TermPM() +{ + if (!mInitialized) + { + return false; + } + + Pm_Terminate(); + + mInitialized = false; + + return true; +} Added: trunk/jazz/src/PortMidiPlayer.h =================================================================== --- trunk/jazz/src/PortMidiPlayer.h (rev 0) +++ trunk/jazz/src/PortMidiPlayer.h 2008-05-26 23:38:36 UTC (rev 568) @@ -0,0 +1,67 @@ +#ifndef JZ_PORTMIDIDRIVER_H +#define JZ_PORTMIDIDRIVER_H + +#include "Player.h" + +#include "../portmidi/pm_common/portmidi.h" +#include "../portmidi/porttime/porttime.h" + +class JZSong; +class JZEvent; + +class JZPortMidiPlayer : public JZPlayer +{ + public: + + JZPortMidiPlayer(JZSong* pSong); + + virtual ~JZPortMidiPlayer(); + + int Installed(); + int SupportsMultipleDevices(); + + virtual tDeviceList& GetInputDevices(); + wxString GetInputDeviceName(); + void SetInputDevice(const wxString& Name); + + virtual tDeviceList& GetOutputDevices(); + wxString GetOutputDeviceName(); + void SetOutputDevice(const wxString& Name); + + int OutEvent(JZEvent* pEvent, int now); + int OutEvent(JZEvent* pEvent); + void OutNow(JZEvent* pEvent); + void OutBreak(); + + void StartPlay(int Clock, int LoopClock = 0, int Continue = 0); + void StopPlay(); + + long GetRealTimeClock(); + int Clock2Time(int clock); + int Time2Clock(int time); + void SetTempo(int bpm, int clock); + + private: + + bool InitPM(); + bool TermPM(); + PmDeviceID FindDevice(const wxString & name, bool input); + + private: + + tDeviceList mInputDevices; + tDeviceList mOutputDevices; + + PortMidiStream* mpStream; + + bool mInitialized; + int mStartTime; + int mStartClock; + int mTicksPerMinute; + wxString mInputDevice; + wxString mOutputDevice; + int mInDev; + int mOutDev; +}; + +#endif // !defined(JZ_PORTMIDIDRIVER_H) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-27 14:01:34
|
Revision: 579 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=579&view=rev Author: pstieber Date: 2008-05-27 07:01:15 -0700 (Tue, 27 May 2008) Log Message: ----------- 1. Changed the input and output device indexes from long to int for the Windows settings dialog. 2. Changed Installed member function to IsInstalled for all of the players and changed then corresponding data member from installed to mInstalled. 3. Added code for to use the portmidi device selection dialog in the project. 4. Made cosmetic changes in the portmidi player class. 5. Changed the configuration code to use strings instead of char* in several places. 6. Removed the configuration code that read and wrote long values. 7. Changed JZConfiguration::Check to tokenize the passed line using a new function in Globals.cpp. 8. Changed some I/O in the configuration class from C-style to C++ stream. More to come in this area. Modified Paths: -------------- trunk/jazz/src/AlsaDriver.cpp trunk/jazz/src/AlsaDriver.h trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/AlsaPlayer.h trunk/jazz/src/AudioDriver.cpp trunk/jazz/src/AudioDriver.h trunk/jazz/src/Configuration.cpp trunk/jazz/src/Configuration.h trunk/jazz/src/Dialogs/midiTiming.cpp trunk/jazz/src/Globals.cpp trunk/jazz/src/Globals.h trunk/jazz/src/MidiDeviceDialog.cpp trunk/jazz/src/MidiDeviceDialog.h trunk/jazz/src/Player.cpp trunk/jazz/src/Player.h trunk/jazz/src/PortMidiPlayer.cpp trunk/jazz/src/PortMidiPlayer.h trunk/jazz/src/Project.cpp trunk/jazz/src/TrackFrame.cpp trunk/jazz/src/mswin/WindowsAudioInterface.cpp trunk/jazz/src/mswin/WindowsAudioInterface.h trunk/jazz/src/mswin/WindowsPlayer.cpp trunk/jazz/src/mswin/WindowsPlayer.h Modified: trunk/jazz/src/AlsaDriver.cpp =================================================================== --- trunk/jazz/src/AlsaDriver.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/AlsaDriver.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -127,7 +127,7 @@ : tAlsaPlayer(pSong) { AudioBuffer = new tEventArray(); - installed = 0; + mInstalled = false; audio_enabled = 0; mpListener = 0; mCanDuplex = 0; // no duplex yet. @@ -139,7 +139,7 @@ // FIXME mCanDuplex = 1; - installed = 1; + mInstalled = true; audio_enabled = 1; } Modified: trunk/jazz/src/AlsaDriver.h =================================================================== --- trunk/jazz/src/AlsaDriver.h 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/AlsaDriver.h 2008-05-27 14:01:15 UTC (rev 579) @@ -43,7 +43,10 @@ virtual void Notify(); virtual void StartPlay(long Clock, long LoopClock = 0, int Continue = 0); virtual void StopPlay(); - virtual int Installed() { return installed && tAlsaPlayer::Installed(); } + virtual bool IsInstalled() + { + return mInstalled && tAlsaPlayer::IsInstalled(); + } virtual int GetAudioEnabled() const { return audio_enabled; } virtual void SetAudioEnabled(int x) { audio_enabled = x; } virtual void ListenAudio(int key, int start_stop_mode = 1); @@ -82,7 +85,7 @@ int mCanDuplex; snd_pcm_t *pcm[2]; - int installed; + bool mInstalled; long audio_clock_offset; long cur_pos; Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -54,7 +54,7 @@ { ithru = othru = 0; - installed = 1; + mInstalled = true; poll_millisec = 25; recd_clock = 0; echo_clock = 0; @@ -62,14 +62,14 @@ if (snd_seq_open(&handle, "hw", SND_SEQ_OPEN_DUPLEX, 0) < 0) { perror("open sequencer"); - installed = 0; + mInstalled = false; return; } // set myself into non blocking mode if (set_blocking_mode(0) < 0) { - installed = 0; + mInstalled = false; return; } client = snd_seq_client_id(handle); @@ -190,7 +190,7 @@ snd_seq_set_output_buffer_size(handle, 65536); - if (installed) + if (mInstalled) { thru = new tAlsaThru(); SetSoftThru( @@ -381,9 +381,9 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tAlsaPlayer::Installed() +bool tAlsaPlayer::IsInstalled() { - return installed; + return mInstalled; } //----------------------------------------------------------------------------- Modified: trunk/jazz/src/AlsaPlayer.h =================================================================== --- trunk/jazz/src/AlsaPlayer.h 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/AlsaPlayer.h 2008-05-27 14:01:15 UTC (rev 579) @@ -50,7 +50,7 @@ virtual ~tAlsaPlayer(); void Notify(); - int Installed(); + bool IsInstalled(); int OutEvent(JZEvent *e, int now); int OutEvent(JZEvent *e) { return OutEvent(e, 0); } void OutNow(JZEvent *e) { OutEvent(e, 1); } @@ -79,7 +79,7 @@ int sync_in, sync_in_dev, sync_in_mtcType; int sync_out, sync_out_dev, sync_out_mtcType; - int installed; + bool mInstalled; static int create_port(snd_seq_t *handle, const char *name); static void set_client_info(snd_seq_t *handle, const char *name); Modified: trunk/jazz/src/AudioDriver.cpp =================================================================== --- trunk/jazz/src/AudioDriver.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/AudioDriver.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -39,6 +39,8 @@ #define AUDIO_DEVICE "/dev/dsp" +//***************************************************************************** +//***************************************************************************** class tAudioListener : public wxTimer { public: @@ -115,14 +117,14 @@ int mHardExit; }; - - -tAudioPlayer::tAudioPlayer(JZSong *song) - : tSeq2Player(song) +//***************************************************************************** +//***************************************************************************** +tAudioPlayer::tAudioPlayer(JZSong* pSong) + : tSeq2Player(pSong) { long dummy = 0; AudioBuffer = new tEventArray(); - installed = 0; + mInstalled = false; dummy = gpConfig->GetValue(C_EnableAudio); audio_enabled = dummy; mpListener = 0; @@ -152,7 +154,7 @@ } else { - installed = 1; + mInstalled = true; } close(dev); @@ -163,7 +165,7 @@ } dev = -1; // closed - audio_enabled = audio_enabled && installed; + audio_enabled = audio_enabled && mInstalled; } Modified: trunk/jazz/src/AudioDriver.h =================================================================== --- trunk/jazz/src/AudioDriver.h 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/AudioDriver.h 2008-05-27 14:01:15 UTC (rev 579) @@ -60,9 +60,9 @@ virtual void StartAudio(); - virtual int Installed() + virtual int IsIsInstalled() { - return installed && tSeq2Player::Installed(); + return mInstalled && tSeq2Player::IsInstalled(); } virtual int GetAudioEnabled() const @@ -107,7 +107,7 @@ void CloseDsp(bool Reset); int dev; - int installed; + bool mInstalled; long midi_clock; long audio_bytes; Modified: trunk/jazz/src/Configuration.cpp =================================================================== --- trunk/jazz/src/Configuration.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/Configuration.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -32,6 +32,7 @@ #include <stack> #include <iostream> #include <sstream> +#include <fstream> using namespace std; @@ -407,20 +408,28 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZConfiguration::Check(const char* pName) const +int JZConfiguration::Check(const string& InputLine) const { - if (!pName || (pName[0] != '.')) + string::const_iterator iString = InputLine.begin(); + + if (iString == InputLine.end() || *iString != '.') { return -1; } + const string Delimiters(" \t"); + + vector<string> Tokens; + + Tokenize(InputLine, Delimiters, Tokens); + for (int i = 0; i < NumConfigNames; i++) { if (!mNames[i]) { continue; } - if (!strncmp(pName, mNames[i]->GetName(), strlen(mNames[i]->GetName()))) + if (Tokens[0] == mNames[i]->GetName()) { // Found return i; @@ -475,7 +484,7 @@ else if (mNames[entry]->GetType() == eConfigEntryTypeStr) { // Allow whitespace inside entries like "C:\Program Files\JazzWare". - int ofs = strlen(mNames[entry]->GetName()); + int ofs = mNames[entry]->GetName().length(); while (buf[ofs] == ' ' || buf[ofs] == '\t') // not \n { ++ofs; @@ -531,7 +540,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -bool JZConfiguration::Get(int entry, char *value) +bool JZConfiguration::Get(int entry, char* value) { assert((entry >= 0) && (entry < NumConfigNames)); @@ -542,14 +551,14 @@ } FILE *fd = fopen(FileName.c_str(), "r"); - const char* name = GetName(entry); + const string& name = GetName(entry); - int len = strlen(name); + int len = name.length(); char buf[1000]; bool found = false; while (!found && fgets(buf, sizeof(buf), fd) != NULL) { - if (strncmp(buf, name, len) == 0) + if (strncmp(buf, name.c_str(), len) == 0) { while (isspace(buf[len])) { @@ -570,12 +579,12 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -bool JZConfiguration::Get(int entry, long &value) +bool JZConfiguration::Get(int entry, int& value) { char buf[512]; if (Get(entry, buf)) { - sscanf(buf, " %ld ", &value); + sscanf(buf, " %d ", &value); return true; } return false; @@ -587,7 +596,7 @@ // entries to there. If the name/value pair is found, replace it, otherwise // write it. Finally copy the temp file over the old configuration file. //----------------------------------------------------------------------------- -bool JZConfiguration::Put(int Index, const char *value) +bool JZConfiguration::Put(int Index, const string& ValueString) { assert((Index >= 0) && (Index < NumConfigNames)); @@ -597,61 +606,53 @@ return false; } - char tempname[512]; - strcpy(tempname, FileName.c_str()); - strcat(tempname, ".tmp"); //make the temp file name - FILE *out = fopen(tempname, "w"); - if (!out) + // Create a temporary file name from the current file name. + string TempFileName(FileName); + TempFileName.append(".tmp"); + ofstream Os(TempFileName.c_str()); + if (!Os) { return false; } FILE* inp = fopen(FileName.c_str(), "r"); - const char* name = GetName(Index); + const string& name = GetName(Index); - int len = strlen(name); + int len = name.length(); char buf[1000]; bool found = false; while (fgets(buf, sizeof(buf), inp) != NULL) { - if (strncmp(buf, name, len) == 0) + if (strncmp(buf, name.c_str(), len) == 0) { - fprintf(out, "%s %s\n", name, value); + Os << name << ' ' << ValueString << endl; found = true; } else { - fputs(buf, out); + Os << buf; } } if (!found) { - fprintf(out, "%s %s\n", name, value); + Os << name << ' ' << ValueString << endl; } fclose(inp); - fclose(out); + Os.close(); + unlink(FileName.c_str()); - rename(tempname, FileName.c_str()); + rename(TempFileName.c_str(), FileName.c_str()); return true; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -bool JZConfiguration::Put(int Index, long Value) -{ - ostringstream Oss; - Oss << Value; - return Put(Index, Oss.str().c_str()); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- bool JZConfiguration::Put(int Index) { assert((Index >= 0) && (Index < NumConfigNames)); mNames[Index]->SetValue(Index); - long LongValue = mNames[Index]->GetValue(); - return Put(Index, LongValue); + int Value = mNames[Index]->GetValue(); + return Put(Index, Value); } //----------------------------------------------------------------------------- @@ -660,8 +661,9 @@ { assert((Index >= 0) && (Index < NumConfigNames)); mNames[Index]->SetValue(Value); - long LongValue = mNames[Index]->GetValue(); - return Put(Index, LongValue); + ostringstream Oss; + Oss << Value; + return Put(Index, Oss.str()); } //----------------------------------------------------------------------------- @@ -692,6 +694,7 @@ vector<pair<string, int> >* pVector = 0; +// stack<ifstream> InputFileStreams; stack<FILE*> FileDescriptors; cout @@ -699,7 +702,11 @@ << " \"" << mFileName << '"' << endl; +// ifstream Is(mFileName.c_str()); +// InputFileStreams.push(Is); FileDescriptors.push(fopen(mFileName.c_str(), "r")); + +// if (!InputFileStreams.top()) if (FileDescriptors.top() == NULL) { wxString String; @@ -719,10 +726,17 @@ while (1) { // Read a line from the current file. + +// if (getline(InputFileStreams.top(), InputLine)) if (fgets(buf, sizeof(buf), FileDescriptors.top()) == NULL) { +// InputFileStreams.top().close(); fclose(FileDescriptors.top()); + +// InputFileStreams.pop(); FileDescriptors.pop(); + +// if (InputFileStreams.empty()) if (FileDescriptors.empty()) { // The code has reached the last line of the Jazz++ configuration file @@ -800,13 +814,16 @@ if (IncludeFileName.empty()) { +// InputFileStreams FileDescriptors.push(NULL); } else { +// InputFileStreams FileDescriptors.push(fopen(IncludeFileName, "r")); } +// InputFileStreams if (FileDescriptors.top() == NULL) { wxString String; @@ -814,6 +831,8 @@ << "Could not open configuration include file:" << '\n' << '"' << buf << '"'; ::wxMessageBox(String, "Warning", wxOK); + +// InputFileStreams.pop(); FileDescriptors.pop(); } } Modified: trunk/jazz/src/Configuration.h =================================================================== --- trunk/jazz/src/Configuration.h 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/Configuration.h 2008-05-27 14:01:15 UTC (rev 579) @@ -144,7 +144,7 @@ TEConfigEntryType GetType() const; - const char* GetName() const; + const std::string& GetName() const; const int& GetValue() const; @@ -177,9 +177,9 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- inline -const char* JZConfigurationEntry::GetName() const +const std::string& JZConfigurationEntry::GetName() const { - return mName.c_str(); + return mName; } //----------------------------------------------------------------------------- @@ -218,31 +218,30 @@ void LoadConfig(const wxString& FileName); - int Check(const char* pName) const; + int Check(const std::string& Name) const; int Load(char* buf); - const std::pair<std::string, int>& GetDrumName(unsigned entry) const; - const std::pair<std::string, int>& GetDrumSet(unsigned entry) const; - const std::pair<std::string, int>& GetVoiceName(unsigned entry) const; - const std::pair<std::string, int>& GetCtrlName(unsigned entry) const; + const std::pair<std::string, int>& GetDrumName(unsigned Entry) const; + const std::pair<std::string, int>& GetDrumSet(unsigned Entry) const; + const std::pair<std::string, int>& GetVoiceName(unsigned Entry) const; + const std::pair<std::string, int>& GetCtrlName(unsigned Entry) const; - JZDoubleCommand& BankEntry(unsigned entry); + JZDoubleCommand& BankEntry(unsigned Entry); - const char* GetName(int entry) const; + const std::string& GetName(int Entry) const; - const std::string& GetStrValue(int entry) const; + const std::string& GetStrValue(int Entry) const; const int& GetValue(const char* pName) const; const int& GetValue(int Index) const; - bool Get(int entry, char* value); - bool Get(int entry, long& value); + bool Get(int Entry, char* pValue); + bool Get(int Entry, int& Value); - bool Put(int entry, const char *value); - bool Put(int entry, long value); - bool Put(int entry); - bool Put(int entry, int value); + bool Put(int Entry, const std::string& ValueString); + bool Put(int Entry); + bool Put(int Entry, int Value); const std::vector<std::pair<std::string, int> >& GetDrumSets() const; @@ -284,19 +283,19 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- inline -const char* JZConfiguration::GetName(int entry) const +const std::string& JZConfiguration::GetName(int Entry) const { - assert((entry >= 0) && (entry < NumConfigNames)); - return mNames[entry]->GetName(); + assert((Entry >= 0) && (Entry < NumConfigNames)); + return mNames[Entry]->GetName(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- inline -const std::string& JZConfiguration::GetStrValue(int entry) const +const std::string& JZConfiguration::GetStrValue(int Entry) const { - assert((entry >= 0) && (entry < NumConfigNames)); - return mNames[entry]->GetStrValue(); + assert((Entry >= 0) && (Entry < NumConfigNames)); + return mNames[Entry]->GetStrValue(); } //----------------------------------------------------------------------------- Modified: trunk/jazz/src/Dialogs/midiTiming.cpp =================================================================== --- trunk/jazz/src/Dialogs/midiTiming.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/Dialogs/midiTiming.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -62,9 +62,9 @@ Config(C_ClockSource) = CsMtc; ClkSrcListBox->SetStringSelection( ClkSrcArray[ Config(C_ClockSource) ] ); Midi = new JZWindowsMtcPlayer(EventWin->Song); - if (!Midi->Installed()) + if (!Midi->IsInstalled()) { - wxMessageBox("no midi driver installed", "Error", wxOK); + wxMessageBox("no MIDI driver installed", "Error", wxOK); Midi = new tNullPlayer(EventWin->Song); } } @@ -149,9 +149,9 @@ Midi = new tWinAudioPlayer(EventWin->Song); break; } - if (!Midi->Installed()) + if (!Midi->IsInstalled()) { - wxMessageBox("no midi driver installed", "Error", wxOK); + wxMessageBox("no MIDI driver installed", "Error", wxOK); Midi = new tNullPlayer(EventWin->Song); } #endif Modified: trunk/jazz/src/Globals.cpp =================================================================== --- trunk/jazz/src/Globals.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/Globals.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -67,3 +67,42 @@ const double gDegreesToRadians = 0.01745329251994330212; const double gRadiansToDegrees = 57.2957795130823; + +//***************************************************************************** +// Decsription: +// This function tokenizes the input string. +//***************************************************************************** +int Tokenize( + const string& String, + const string& Delimiters, + vector<string>& Tokens) +{ + string::size_type Begin, End; + + // Initialize the token index. + int TokenIndex = 0; + + // Search the beginning of the line for the first token. + Begin = String.find_first_not_of(Delimiters); + + // While at the beginning of a word found. + while (Begin != string::npos) + { + // Search for the end of the actual token. + End = String.find_first_of(Delimiters, Begin); + + if (End == string::npos) + { + End = String.length(); + } + + Tokens.push_back(String.substr(Begin, End - Begin)); + + ++TokenIndex; + + Begin = String.find_first_not_of(Delimiters, End); + } + + return TokenIndex; +} + Modified: trunk/jazz/src/Globals.h =================================================================== --- trunk/jazz/src/Globals.h 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/Globals.h 2008-05-27 14:01:15 UTC (rev 579) @@ -65,4 +65,11 @@ extern const double gDegreesToRadians; extern const double gRadiansToDegrees; +//***************************************************************************** +//***************************************************************************** +int Tokenize( + const std::string& String, + const std::string& Delimiters, + std::vector<std::string>& Tokens); + #endif // !defined(JZ_GLOBALS_H) Modified: trunk/jazz/src/MidiDeviceDialog.cpp =================================================================== --- trunk/jazz/src/MidiDeviceDialog.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/MidiDeviceDialog.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -40,7 +40,7 @@ //----------------------------------------------------------------------------- JZMidiDeviceDialog::JZMidiDeviceDialog( const vector<pair<string, int> >& MidiDevices, - long& DeviceIndex, + int& DeviceIndex, wxWindow* pParent, const wxString& Title) : wxDialog(pParent, wxID_ANY, Title), Modified: trunk/jazz/src/MidiDeviceDialog.h =================================================================== --- trunk/jazz/src/MidiDeviceDialog.h 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/MidiDeviceDialog.h 2008-05-27 14:01:15 UTC (rev 579) @@ -36,7 +36,7 @@ JZMidiDeviceDialog( const std::vector<std::pair<std::string, int> >& MidiDevices, - long& DeviceIndex, + int& DeviceIndex, wxWindow* pParent = 0, const wxString& Title = wxEmptyString); @@ -46,7 +46,7 @@ private: - long& mDeviceIndex; + int& mDeviceIndex; wxListBox* mpMidiDeviceListBox; Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/Player.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -686,7 +686,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tMpuPlayer::Installed() +bool tMpuPlayer::IsInstalled() { return dev >= 0; } @@ -1483,7 +1483,7 @@ if (mididev < 0) { - return; // Installed() == FALSE + return; // IsInstalled() == FALSE } } @@ -1509,7 +1509,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tSeq2Player::Installed() +bool tSeq2Player::IsInstalled() { return seqfd >= 0 && mididev >= 0; } Modified: trunk/jazz/src/Player.h =================================================================== --- trunk/jazz/src/Player.h 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/Player.h 2008-05-27 14:01:15 UTC (rev 579) @@ -38,7 +38,8 @@ class JZRecordingInfo; - +//***************************************************************************** +//***************************************************************************** class tPlayLoop { public: @@ -71,6 +72,8 @@ long mStopClock; }; +//***************************************************************************** +//***************************************************************************** enum tClockSource { CsInt = 0, @@ -79,6 +82,8 @@ CsMtc }; +//***************************************************************************** +//***************************************************************************** class tDeviceList { public: @@ -124,6 +129,8 @@ tDeviceList& operator = (const tDeviceList &); }; +//***************************************************************************** +//***************************************************************************** class JZPlayer : public wxTimer { protected: @@ -139,7 +146,9 @@ bool Playing; // successful StartPlay - virtual int Installed() = 0; // Hardware found + // Tests if hardware found and successfully setup. + virtual bool IsInstalled() = 0; + // if unable to install, pop up a messagebox explaining why. virtual void ShowError(); @@ -280,15 +289,17 @@ extern char *midinethost; -// -------------------------------------------------------- +//***************************************************************************** // Roland MPU 401 -// -------------------------------------------------------- +//***************************************************************************** #ifdef DEV_MPU401 #include <unistd.h> #include <fcntl.h> +//***************************************************************************** +//***************************************************************************** class tBuffer : public tWriteBase { @@ -440,6 +451,8 @@ #define ACTIVE_TRACKS 7 #define ACTIVE_TRACKS_MASK 0x7f +//***************************************************************************** +//***************************************************************************** class tMpuPlayer : public JZPlayer { int dev; @@ -465,7 +478,7 @@ void StartPlay(long Clock, long LoopClock = 0, int Continue = 0); void StopPlay(); long GetRealTimeClock(); - int Installed(); + virtual bool IsInstalled(); long GetRecordedData(); void SetHardThru(int on, int idev, int odev); @@ -482,8 +495,10 @@ #endif // DEV_MPU401 -// ------------------------------ null-driver ------------------------------- - +//***************************************************************************** +// Description: +// This is the null driver class declaration. +//***************************************************************************** class tNullPlayer : public JZPlayer { public: @@ -493,9 +508,9 @@ { } - int Installed() + virtual bool IsInstalled() { - return 1; + return true; } virtual ~tNullPlayer() @@ -544,6 +559,8 @@ void seqbuf_flush_last_event(); +//***************************************************************************** +//***************************************************************************** class tOSSThru : public wxTimer { public: @@ -552,14 +569,15 @@ ~tOSSThru(); }; - - +//***************************************************************************** +//***************************************************************************** class tSeq2Player : public JZPlayer { public: + friend class tOSSThru; tSeq2Player(JZSong *song); - int Installed(); + virtual bool IsInstalled(); virtual ~tSeq2Player(); int OutEvent(JZEvent *e, int now); int OutEvent(JZEvent *e) { OutEvent(e, 0); return 0; } Modified: trunk/jazz/src/PortMidiPlayer.cpp =================================================================== --- trunk/jazz/src/PortMidiPlayer.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/PortMidiPlayer.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -1,10 +1,19 @@ #include "WxWidgets.h" #include "PortMidiPlayer.h" +#include "JazzPlusPlusApplication.h" +#include "TrackFrame.h" #include "TrackWindow.h" #include "Song.h" #include "Globals.h" +#include "MidiDeviceDialog.h" +#include <iostream> + +using namespace std; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- JZPortMidiPlayer::JZPortMidiPlayer(JZSong* pSong) : JZPlayer(pSong), mInputDevices(), @@ -29,96 +38,102 @@ // mOutputQueue = Pm_QueueCreate(1024, sizeof(PmEvent)); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- JZPortMidiPlayer::~JZPortMidiPlayer() { // Pm_QueueDestroy(mOutputQueue); TermPM(); } -int -JZPortMidiPlayer::Installed() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZPortMidiPlayer::IsInstalled() { return true; } -wxString -JZPortMidiPlayer::GetInputDeviceName() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +wxString JZPortMidiPlayer::GetInputDeviceName() { return mInputDevice; } -wxString -JZPortMidiPlayer::GetOutputDeviceName() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +wxString JZPortMidiPlayer::GetOutputDeviceName() { return mOutputDevice; } - -void -JZPortMidiPlayer::SetInputDevice(const wxString & name) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPortMidiPlayer::SetInputDevice(const wxString& Name) { - bool term = InitPM(); - PmDeviceID id = FindDevice(name, true); + bool NeedToTerminate = InitPM(); + PmDeviceID id = FindDevice(Name, true); if (id != pmNoDevice) { - mInputDevice = name; + mInputDevice = Name; } - if (term) + if (NeedToTerminate) { TermPM(); } } -void -JZPortMidiPlayer::SetOutputDevice(const wxString& name) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPortMidiPlayer::SetOutputDevice(const wxString& Name) { - bool term = InitPM(); - PmDeviceID id = FindDevice(name, false); + bool NeedToTerminate = InitPM(); + PmDeviceID id = FindDevice(Name, false); if (id != pmNoDevice) { - mOutputDevice = name; + mOutputDevice = Name; } - if (term) + if (NeedToTerminate) { TermPM(); } } -int -JZPortMidiPlayer::SupportsMultipleDevices() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZPortMidiPlayer::SupportsMultipleDevices() { return true; } -tDeviceList& -JZPortMidiPlayer::GetOutputDevices() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +tDeviceList& JZPortMidiPlayer::GetOutputDevices() { - bool term = InitPM(); - int cnt; + bool NeedToTerminate = InitPM(); + int Count = Pm_CountDevices(); - cnt = Pm_CountDevices(); - mOutputDevices.Clear(); - for (int i = 0; i < cnt; i++) + for (int i = 0; i < Count; ++i) { - const PmDeviceInfo *di = Pm_GetDeviceInfo(i); + const PmDeviceInfo* pPmDeviceInfo = Pm_GetDeviceInfo(i); - if (di && di->output) + if (pPmDeviceInfo && pPmDeviceInfo->output) { - wxString name = - wxString(di->interf, wxConvISO8859_1) + + wxString Name = + wxString(pPmDeviceInfo->interf, wxConvISO8859_1) + wxT(", ") + - wxString(di->name, wxConvISO8859_1); - mOutputDevices.Add(name); + wxString(pPmDeviceInfo->name, wxConvISO8859_1); + mOutputDevices.Add(Name); } } - if (term) + if (NeedToTerminate) { TermPM(); } @@ -126,31 +141,30 @@ return mOutputDevices; } -tDeviceList& -JZPortMidiPlayer::GetInputDevices() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +tDeviceList& JZPortMidiPlayer::GetInputDevices() { - bool term = InitPM(); - int cnt; - - cnt = Pm_CountDevices(); + bool NeedToTerminate = InitPM(); + int Count = Pm_CountDevices(); mInputDevices.Clear(); - for (int i = 0; i < cnt; i++) + for (int i = 0; i < Count; ++i) { - const PmDeviceInfo *di = Pm_GetDeviceInfo(i); + const PmDeviceInfo* pPmDeviceInfo = Pm_GetDeviceInfo(i); - if (di && di->input) + if (pPmDeviceInfo && pPmDeviceInfo->input) { - wxString name = - wxString(di->interf, wxConvISO8859_1) + + wxString Name = + wxString(pPmDeviceInfo->interf, wxConvISO8859_1) + wxT(", ") + - wxString(di->name, wxConvISO8859_1); - mInputDevices.Add(name); + wxString(pPmDeviceInfo->name, wxConvISO8859_1); + mInputDevices.Add(Name); } } - if (term) + if (NeedToTerminate) { TermPM(); } @@ -158,23 +172,24 @@ return mInputDevices; } -PmDeviceID -JZPortMidiPlayer::FindDevice(const wxString & name, bool input) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +PmDeviceID JZPortMidiPlayer::FindDevice(const wxString& Name, bool input) { - int cnt = Pm_CountDevices(); + int Count = Pm_CountDevices(); - for (int i = 0; i < cnt; i++) + for (int i = 0; i < Count; i++) { - const PmDeviceInfo *di = Pm_GetDeviceInfo(i); + const PmDeviceInfo* pPmDeviceInfo = Pm_GetDeviceInfo(i); - if (di && (input ? di->input : di->output)) + if (pPmDeviceInfo && (input ? pPmDeviceInfo->input : pPmDeviceInfo->output)) { wxString n = - wxString(di->interf, wxConvISO8859_1) + + wxString(pPmDeviceInfo->interf, wxConvISO8859_1) + wxT(", ") + - wxString(di->name, wxConvISO8859_1); + wxString(pPmDeviceInfo->name, wxConvISO8859_1); - if (name == n) + if (Name == n) { return i; } @@ -184,8 +199,9 @@ return pmNoDevice; } -int -JZPortMidiPlayer::Clock2Time(int clock) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZPortMidiPlayer::Clock2Time(int clock) { if (clock < mStartClock) { @@ -195,8 +211,9 @@ return (int)((double)(clock - mStartClock) * 60000.0 / (double) mTicksPerMinute + mStartTime); } -int -JZPortMidiPlayer::Time2Clock(int time) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZPortMidiPlayer::Time2Clock(int time) { if (time < mStartTime) { @@ -206,8 +223,9 @@ return (int)((double)(time - mStartTime) * (double) mTicksPerMinute / 60000.0 + mStartClock); } -void -JZPortMidiPlayer::SetTempo(int bpm, int clock) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPortMidiPlayer::SetTempo(int bpm, int clock) { int t1 = Clock2Time(clock); mTicksPerMinute = bpm * Song->GetTicksPerQuarter(); @@ -215,13 +233,15 @@ mStartTime += (t1 - t2); } -void -JZPortMidiPlayer::OutBreak() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPortMidiPlayer::OutBreak() { } -int -JZPortMidiPlayer::OutEvent(JZEvent* pEvent, int now) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZPortMidiPlayer::OutEvent(JZEvent* pEvent, int now) { PmError rc = pmNoError; PmTimestamp t = (now ? 0 : pEvent->GetClock()); @@ -321,27 +341,30 @@ return rc != pmNoError; } -int -JZPortMidiPlayer::OutEvent(JZEvent* pEvent) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZPortMidiPlayer::OutEvent(JZEvent* pEvent) { return OutEvent(pEvent, 0); } -void -JZPortMidiPlayer::OutNow(JZEvent*pEvent) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPortMidiPlayer::OutNow(JZEvent*pEvent) { OutEvent(pEvent, 1); } -void -JZPortMidiPlayer::StartPlay(int clock, int loopClock, int cont) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPortMidiPlayer::StartPlay(int clock, int loopClock, int cont) { - bool term = InitPM(); + bool NeedToTerminate = InitPM(); PmDeviceID id = FindDevice(mOutputDevice, false); if (id == pmNoDevice) { - if (term) + if (NeedToTerminate) { TermPM(); } @@ -349,7 +372,10 @@ return; } - printf("rc = %d %d\n", Pm_OpenOutput(&mpStream, id, NULL, 0, NULL, NULL, 100), id); + cout + << "rc = " << Pm_OpenOutput(&mpStream, id, NULL, 0, NULL, NULL, 100) + << ' ' << id + << endl; mStartTime = Pt_Time() + 500; mStartClock = clock; @@ -358,8 +384,9 @@ JZPlayer::StartPlay(clock, loopClock, cont); } -void -JZPortMidiPlayer::StopPlay() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPortMidiPlayer::StopPlay() { JZPlayer::StopPlay(); @@ -373,18 +400,21 @@ TermPM(); } -long -JZPortMidiPlayer::GetRealTimeClock() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +long JZPortMidiPlayer::GetRealTimeClock() { long t = Pt_Time(); - gpTrackWindow->NewPlayPosition(PlayLoop->Ext2IntClock(Time2Clock(t) / 48 * 48)); + gpTrackWindow->NewPlayPosition( + PlayLoop->Ext2IntClock(Time2Clock(t) / 48 * 48)); return Time2Clock(t); } -bool -JZPortMidiPlayer::InitPM() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZPortMidiPlayer::InitPM() { if (mInitialized) { @@ -398,8 +428,9 @@ return true; } -bool -JZPortMidiPlayer::TermPM() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZPortMidiPlayer::TermPM() { if (!mInitialized) { @@ -412,3 +443,109 @@ return true; } + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPortMidiPlayer::DeviceSelectionDialog() +{ + // Create a list of devices. + bool NeedToTerminate = InitPM(); + int Count = Pm_CountDevices(); + + vector<pair<string, int> > MidiDevices; + + // Create a container of input devices. + for (int i = 0; i < Count; ++i) + { + const PmDeviceInfo* pPmDeviceInfo = Pm_GetDeviceInfo(i); + + if (pPmDeviceInfo && pPmDeviceInfo->input) + { + wxString Name = + wxString(pPmDeviceInfo->interf, wxConvISO8859_1) + + wxT(", ") + + wxString(pPmDeviceInfo->name, wxConvISO8859_1); + + MidiDevices.push_back(make_pair(Name.c_str(), i)); + } + } + + // Select the input device. + int InputDevice = -1; + if (!MidiDevices.empty()) + { + JZMidiDeviceDialog MidiInputDeviceDialog( + MidiDevices, + InputDevice, + ::wxGetApp().GetMainFrame(), + "Input MIDI device"); + MidiInputDeviceDialog.ShowModal(); + + // Set the input device based on the selected integer. + for ( + vector<pair<string, int> >::const_iterator iDevice = + MidiDevices.begin(); + iDevice != MidiDevices.end(); + ++iDevice) + { + if (iDevice->second == InputDevice) + { + SetOutputDevice(iDevice->first.c_str()); + break; + } + } + } + + MidiDevices.clear(); + + // Create a container of output devices. + for (int i = 0; i < Count; ++i) + { + const PmDeviceInfo* pPmDeviceInfo = Pm_GetDeviceInfo(i); + + if (pPmDeviceInfo && pPmDeviceInfo->output) + { + wxString Name = + wxString(pPmDeviceInfo->interf, wxConvISO8859_1) + + wxT(", ") + + wxString(pPmDeviceInfo->name, wxConvISO8859_1); + + MidiDevices.push_back(make_pair(Name.c_str(), i)); + } + } + + // Select the output device. + int OutputDevice = -1; + if (!MidiDevices.empty()) + { + JZMidiDeviceDialog MidiOutputDeviceDialog( + MidiDevices, + OutputDevice, + gpTrackWindow, + "Output MIDI device"); + MidiOutputDeviceDialog.ShowModal(); + + // Set the output device based on the selected integer. + for ( + vector<pair<string, int> >::const_iterator iDevice = + MidiDevices.begin(); + iDevice != MidiDevices.end(); + ++iDevice) + { + if (iDevice->second == OutputDevice) + { + SetOutputDevice(iDevice->first.c_str()); + break; + } + } + } + +// gpConfig->Put(C_WinInputDevice, InputDevice); + +// gpConfig->Put(C_WinOutputDevice, OutputDevice); + + if (NeedToTerminate) + { + TermPM(); + } +} Modified: trunk/jazz/src/PortMidiPlayer.h =================================================================== --- trunk/jazz/src/PortMidiPlayer.h 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/PortMidiPlayer.h 2008-05-27 14:01:15 UTC (rev 579) @@ -17,7 +17,7 @@ virtual ~JZPortMidiPlayer(); - int Installed(); + virtual bool IsInstalled(); int SupportsMultipleDevices(); virtual tDeviceList& GetInputDevices(); @@ -41,6 +41,8 @@ int Time2Clock(int time); void SetTempo(int bpm, int clock); + void DeviceSelectionDialog(); + private: bool InitPM(); Modified: trunk/jazz/src/Project.cpp =================================================================== --- trunk/jazz/src/Project.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/Project.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -168,14 +168,14 @@ { #ifdef DEV_SEQUENCER2 mpMidiPlayer = new tAudioPlayer(this); - if (!mpMidiPlayer->Installed()) + if (!mpMidiPlayer->IsInstalled()) { cerr << "tAudioPlayer didn't install." << endl; delete mpMidiPlayer; mpMidiPlayer = new tSeq2Player(this); } - if (!mpMidiPlayer->Installed()) + if (!mpMidiPlayer->IsInstalled()) { cerr << "tSeq2Player didn't install." << endl; @@ -195,14 +195,14 @@ { #ifdef DEV_ALSA mpMidiPlayer = new tAlsaAudioPlayer(this); - if (!mpMidiPlayer->Installed()) + if (!mpMidiPlayer->IsInstalled()) { cerr << "tAlsaAudioPlayer didn't install." << endl; delete mpMidiPlayer; mpMidiPlayer = new tAlsaPlayer(this); } - if (!mpMidiPlayer->Installed()) + if (!mpMidiPlayer->IsInstalled()) { cerr << "tAlsaPlayer didn't install." << endl; @@ -223,7 +223,7 @@ { #ifdef DEV_MPU401 mpMidiPlayer = new tMpuPlayer(this); - if (!mpMidiPlayer->Installed()) + if (!mpMidiPlayer->IsInstalled()) { cerr << "tMpuPlayer didn't install." << endl; @@ -267,7 +267,7 @@ case CsInt: default: mpMidiPlayer = new JZWindowsAudioPlayer(this); - if (!mpMidiPlayer->Installed()) + if (!mpMidiPlayer->IsInstalled()) { mpMidiPlayer->ShowError(); delete mpMidiPlayer; @@ -275,7 +275,7 @@ } break; } - if (!mpMidiPlayer->Installed()) + if (!mpMidiPlayer->IsInstalled()) { mpMidiPlayer->ShowError(); delete mpMidiPlayer; @@ -288,8 +288,12 @@ // Macintosh Drivers //------------------ mpMidiPlayer = new JZPortMidiPlayer(this); - if (!mpMidiPlayer->Installed()) + mpMidiPlayer.DeviceSelectionDialog(); + + if (!mpMidiPlayer->IsInstalled()) { + delete mpMidiPlayer; + mpMidiPlayer = 0; cout << "Jazz++ will start with no play/record ability." << endl; } #endif // __WXMAC__ Modified: trunk/jazz/src/TrackFrame.cpp =================================================================== --- trunk/jazz/src/TrackFrame.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/TrackFrame.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -570,7 +570,7 @@ void JZTrackFrame::OnSettingsMidiDevice(wxCommandEvent& Event) { #ifdef __WXMSW__ - long InputDevice, OutputDevice; + int InputDevice, OutputDevice; gpConfig->Get(C_WinInputDevice, InputDevice); gpConfig->Get(C_WinOutputDevice, OutputDevice); JZWindowsPlayer::SettingsDlg(InputDevice, OutputDevice); Modified: trunk/jazz/src/mswin/WindowsAudioInterface.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsAudioInterface.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/mswin/WindowsAudioInterface.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -157,14 +157,14 @@ long dummy = 0; AudioBuffer = new tEventArray(); - installed = 0; + mInstalled = false; dummy = gpConfig->GetValue(C_EnableAudio); audio_enabled = dummy; hout_open = 0; hinp_open = 0; // check for device - installed = 0; + mInstalled = false; mCanDuplex = (gpConfig->GetValue(C_DuplexAudio) != 0); if (OpenDsp() == 0) @@ -188,11 +188,11 @@ if (!mErrorCode && CloseDsp() == 0) { - installed = 1; + mInstalled = true; } } recbuffers.Clear(); - audio_enabled = (audio_enabled && installed); + audio_enabled = (audio_enabled && mInstalled); } //----------------------------------------------------------------------------- Modified: trunk/jazz/src/mswin/WindowsAudioInterface.h =================================================================== --- trunk/jazz/src/mswin/WindowsAudioInterface.h 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/mswin/WindowsAudioInterface.h 2008-05-27 14:01:15 UTC (rev 579) @@ -66,9 +66,9 @@ virtual void StartAudio(); // called async by driver - virtual int Installed() + virtual bool IsInstalled() { - return installed && JZWindowsIntPlayer::Installed(); + return mInstalled && JZWindowsIntPlayer::IsInstalled(); } virtual int GetAudioEnabled() const @@ -134,7 +134,7 @@ int OpenDsp(); // 0 = ok int CloseDsp(); // 0 = ok - int installed; + bool mInstalled; int audio_enabled; // 0 means midi only long blocks_played; // # of blocks written to device int play_buffers_needed; // driver requests more output buffers Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-05-27 14:01:15 UTC (rev 579) @@ -63,7 +63,7 @@ state->doing_mtc_rec = FALSE; state->audio_player = 0; - long ilong = -1, olong = -1; + int ilong = -1, olong = -1; if ( !gpConfig->Get(C_WinInputDevice, ilong) || !gpConfig->Get(C_WinOutputDevice, olong)) @@ -162,7 +162,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZWindowsPlayer::Installed() +bool JZWindowsPlayer::IsInstalled() { return timer_installed && state->hout; } @@ -996,7 +996,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZWindowsPlayer::SettingsDlg(long& InputDevice, long& OutputDevice) +void JZWindowsPlayer::SettingsDlg(int& InputDevice, int& OutputDevice) { vector<pair<string, int> > MidiDevices; Modified: trunk/jazz/src/mswin/WindowsPlayer.h =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.h 2008-05-27 04:05:06 UTC (rev 578) +++ trunk/jazz/src/mswin/WindowsPlayer.h 2008-05-27 14:01:15 UTC (rev 579) @@ -40,7 +40,7 @@ JZWindowsPlayer(JZSong* pSong); - int Installed(); + virtual bool IsInstalled(); virtual ~JZWindowsPlayer(); virtual int OutEvent(JZEvent* e); virtual int OutSysex(JZEvent* e, DWORD time); @@ -63,7 +63,7 @@ return 0; } - static void SettingsDlg(long& InputDevice, long& OutputDevice); + static void SettingsDlg(int& InputDevice, int& OutputDevice); enum { MAX_MIDI_DEVS = 10 }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-06-11 15:12:19
|
Revision: 597 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=597&view=rev Author: pstieber Date: 2008-06-11 08:12:17 -0700 (Wed, 11 Jun 2008) Log Message: ----------- Added code to register the generated help file. Modified Paths: -------------- trunk/jazz/src/JazzPlusPlusApplication.cpp trunk/jazz/src/JazzPlusPlusApplication.h Modified: trunk/jazz/src/JazzPlusPlusApplication.cpp =================================================================== --- trunk/jazz/src/JazzPlusPlusApplication.cpp 2008-06-11 15:03:03 UTC (rev 596) +++ trunk/jazz/src/JazzPlusPlusApplication.cpp 2008-06-11 15:12:17 UTC (rev 597) @@ -48,11 +48,19 @@ #endif +#include <fstream> + +using namespace std; + //***************************************************************************** // Description: // This is the JazzPlusPlus application class definition. //***************************************************************************** //----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +wxString JZJazzPlusPlusApplication::mHelpFileName = "jazz.hhp"; + +//----------------------------------------------------------------------------- // Description: // Create a new application object using the wxWidgets macro. This macro // will allow wxWidgets to create the application object during program @@ -143,11 +151,110 @@ // Show it and tell the application that it's our main window SetTopWindow(mpTrackFrame); + // Get the current working directory and append a directory separator. + wxString CurrentWorkingDirectory = + ::wxGetCwd() + wxFileName::GetPathSeparator(); + + // This code should be distributed with a HelpFiles subdirectory under + // the directory the executable is stored in. + wxString HelpFileDirectoryGuess = + CurrentWorkingDirectory + "HelpFiles" + wxFileName::GetPathSeparator(); + + // Attempt to obtain the path to the help file from configuration data. + wxString HelpFilePath; + bool WasHelpPathRead = false; + if (pConfig) + { + WasHelpPathRead = pConfig->Read( + "/Paths/Help", + &HelpFilePath, + HelpFileDirectoryGuess); + } + + // Construct a full file name. + wxString HelpFileNameAndPath = HelpFilePath + mHelpFileName; + + // Test for the existence of the help file. + bool HelpFileFound = true; + ifstream Is; + Is.open(HelpFileNameAndPath.c_str()); + if (!Is) + { + // Return a valid path to the data. + FindAndRegisterHelpFilePath(HelpFilePath); + HelpFileNameAndPath = HelpFilePath + mHelpFileName; + + // Try one more time. + Is.close(); + Is.clear(); + Is.open(HelpFileNameAndPath.c_str()); + if (!Is) + { + wxString Message = "Failed to add the IPVT book " + mHelpFileName; + ::wxMessageBox(Message); + HelpFileFound = false; + } + } + + if (HelpFileFound) + { + // The cached version of the help file will be placed in this location. + mHelp.SetTempDir(HelpFilePath); + + // Add the IPVT help file the the help system. + mHelp.AddBook(HelpFileNameAndPath); + + if (!WasHelpPathRead && pConfig) + { + // Register the help path. + pConfig->Write("/Paths/Help", HelpFilePath); + } + } + return true; } //----------------------------------------------------------------------------- +// Description: +// The help file was not found so let the user search for it. If it is +// found, create a configuration entry so the code can find the help file path +// the next time it starts. //----------------------------------------------------------------------------- +void JZJazzPlusPlusApplication::FindAndRegisterHelpFilePath( + wxString& HelpFilePath) +{ + wxString Message; + Message = "Unable to find " + mHelpFileName; + ::wxMessageBox(Message, "Please Locate This File!"); + + // Use an open dialog to find the help file. + wxFileDialog OpenDialog( + 0, + "Open the Help File", + "", + mHelpFileName, + "*.hhp", + wxFD_OPEN); + if (OpenDialog.ShowModal() == wxID_OK) + { + // Generate a c-style string that contains a path to the help file. + wxString TempHelpFilePath; + TempHelpFilePath = ::wxPathOnly(OpenDialog.GetPath()); + TempHelpFilePath += ::wxFileName::GetPathSeparator(); + + wxConfigBase* pConfig = wxConfigBase::Get(); + if (pConfig) + { + pConfig->Write("/Paths/Help", TempHelpFilePath); + } + + // Return the user selected help file path. + HelpFilePath = TempHelpFilePath; + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int JZJazzPlusPlusApplication::OnExit() { delete mpProject; Modified: trunk/jazz/src/JazzPlusPlusApplication.h =================================================================== --- trunk/jazz/src/JazzPlusPlusApplication.h 2008-06-11 15:03:03 UTC (rev 596) +++ trunk/jazz/src/JazzPlusPlusApplication.h 2008-06-11 15:12:17 UTC (rev 597) @@ -90,6 +90,12 @@ private: + void FindAndRegisterHelpFilePath(wxString& HelpFilePath); + + private: + + static wxString mHelpFileName; + JZProject* mpProject; JZTrackFrame* mpTrackFrame; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |