From: <pst...@us...> - 2010-04-05 03:53:49
|
Revision: 744 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=744&view=rev Author: pstieber Date: 2010-04-05 03:53:42 +0000 (Mon, 05 Apr 2010) Log Message: ----------- Getting ready to make the audio dialogs accessible. Modified Paths: -------------- trunk/jazz/src/AlsaDriver.cpp trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/Audio.cpp trunk/jazz/src/Audio.h trunk/jazz/src/AudioDriver.cpp trunk/jazz/src/ControlEdit.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/EventWindow.cpp trunk/jazz/src/EventWindow.h trunk/jazz/src/PianoFrame.cpp trunk/jazz/src/PianoFrame.h trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/PianoWindow.h trunk/jazz/src/Player.cpp trunk/jazz/src/Player.h trunk/jazz/src/PortMidiPlayer.cpp trunk/jazz/src/Project.cpp trunk/jazz/src/Project.h trunk/jazz/src/ProjectManager.cpp trunk/jazz/src/Sample.h trunk/jazz/src/Track.cpp trunk/jazz/src/Track.h trunk/jazz/src/TrackFrame.cpp trunk/jazz/src/TrackFrame.h trunk/jazz/src/TrackWindow.cpp trunk/jazz/src/TrackWindow.h trunk/jazz/src/mswin/WindowsAudioInterface.cpp trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/AlsaDriver.cpp =================================================================== --- trunk/jazz/src/AlsaDriver.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/AlsaDriver.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -125,7 +125,7 @@ tAlsaAudioPlayer::tAlsaAudioPlayer(JZSong* pSong) : tAlsaPlayer(pSong) { - AudioBuffer = new tEventArray(); + mpAudioBuffer = new tEventArray(); mInstalled = false; audio_enabled = 0; mpListener = 0; @@ -146,7 +146,7 @@ tAlsaAudioPlayer::~tAlsaAudioPlayer() { delete mpListener; - delete AudioBuffer; + delete mpAudioBuffer; if (pcm[PLAYBACK]) { snd_pcm_close(pcm[PLAYBACK]); @@ -186,12 +186,12 @@ return; } - long ticks_per_minute = Song->GetTicksPerQuarter() * Song->Speed(); - mSamples.ResetBuffers(AudioBuffer, clock, ticks_per_minute); + long ticks_per_minute = mpSong->GetTicksPerQuarter() * mpSong->Speed(); + mSamples.ResetBuffers(mpAudioBuffer, clock, ticks_per_minute); last_scount = 0; cur_pos = 0; audio_clock_offset = clock; - midi_speed = Song->Speed(); + midi_speed = mpSong->Speed(); curr_speed = midi_speed; running_mode = 0; @@ -208,7 +208,7 @@ { OpenDsp(PLAYBACK, 1); mSamples.ResetBufferSize(frag_byte_size[PLAYBACK]); - mSamples.FillBuffers(OutClock); + mSamples.FillBuffers(mOutClock); } if (running_mode == 0) @@ -412,7 +412,7 @@ WriteSamples(); // The code may hang here when swapping in pages. - mSamples.FillBuffers(OutClock); + mSamples.FillBuffers(mOutClock); WriteSamples(); } @@ -521,8 +521,8 @@ if (pcm[PLAYBACK]) { snd_pcm_drop(pcm[PLAYBACK]); -// long ticks_per_minute = Song->GetTicksPerQuarter() * Song->Speed(); -// mSamples.ResetBuffers(AudioBuffer, clock, ticks_per_minute); +// long ticks_per_minute = mpSong->GetTicksPerQuarter() * mpSong->Speed(); +// mSamples.ResetBuffers(mpAudioBuffer, clock, ticks_per_minute); } audio_clock_offset = clock; cur_pos = 0; Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/AlsaPlayer.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -49,13 +49,13 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -tAlsaPlayer::tAlsaPlayer(JZSong *song) - : JZPlayer(song) +tAlsaPlayer::tAlsaPlayer(JZSong* pSong) + : JZPlayer(pSong) { ithru = othru = 0; mInstalled = true; - poll_millisec = 25; + mPollMillisec = 25; recd_clock = 0; echo_clock = 0; @@ -520,7 +520,7 @@ //----------------------------------------------------------------------------- void tAlsaPlayer::OutBreak() { - OutBreak(OutClock); + OutBreak(mOutClock); } //----------------------------------------------------------------------------- @@ -610,48 +610,48 @@ cout << "tAlsaPlayer::Notify rewind" << endl; ResetPlay(Now); mPlayBuffer.Clear(); - OutClock = Now + FIRST_DELTACLOCK; - PlayLoop->PrepareOutput(&mPlayBuffer, Song, Now, OutClock, 0); - if (AudioBuffer) + mOutClock = Now + FIRST_DELTACLOCK; + mpPlayLoop->PrepareOutput(&mPlayBuffer, mpSong, Now, mOutClock, 0); + if (mpAudioBuffer) { - AudioBuffer->Clear(); - PlayLoop->PrepareOutput(AudioBuffer, Song, Now, OutClock, 1); + mpAudioBuffer->Clear(); + mpPlayLoop->PrepareOutput(mpAudioBuffer, mpSong, Now, mOutClock, 1); } mPlayBuffer.Length2Keyoff(); } else { // time to put more events - if (Now >= (OutClock - ADVANCE_PLAY)) + if (Now >= (mOutClock - ADVANCE_PLAY)) { - PlayLoop->PrepareOutput( + mpPlayLoop->PrepareOutput( &mPlayBuffer, - Song, - OutClock, + mpSong, + mOutClock, Now + DELTACLOCK, 0); - if (AudioBuffer) + if (mpAudioBuffer) { - PlayLoop->PrepareOutput( - AudioBuffer, - Song, - OutClock, + mpPlayLoop->PrepareOutput( + mpAudioBuffer, + mpSong, + mOutClock, Now + DELTACLOCK, 1); } - OutClock = Now + DELTACLOCK; + mOutClock = Now + DELTACLOCK; mPlayBuffer.Length2Keyoff(); } } play_clock = Now; - if (mPlayBuffer.nEvents && mPlayBuffer.Events[0]->GetClock() < OutClock) + if (mPlayBuffer.nEvents && mPlayBuffer.Events[0]->GetClock() < mOutClock) { FlushToDevice(); } else { - OutBreak(); // does nothing unless OutClock has changed + OutBreak(); // does nothing unless mOutClock has changed } } @@ -688,8 +688,8 @@ //----------------------------------------------------------------------------- int tAlsaPlayer::start_timer(long clock) { - int time_base = Song->GetTicksPerQuarter(); - int cur_speed = Song->GetTrack(0)->GetCurrentSpeed(clock); + int time_base = mpSong->GetTicksPerQuarter(); + int cur_speed = mpSong->GetTrack(0)->GetCurrentSpeed(clock); init_queue_tempo(time_base, cur_speed); start_queue_timer(clock); return 0; @@ -923,7 +923,7 @@ { // Not all events are to be recorded. Only those filtered out and put // into the event. - pEvent->SetClock(PlayLoop->Ext2IntClock(ev->time.tick)); + pEvent->SetClock(mpPlayLoop->Ext2IntClock(ev->time.tick)); mRecdBuffer.Put(pEvent); } } @@ -947,7 +947,7 @@ if (recd_clock != old_recd_clock) { JZProjectManager::Instance()->NewPlayPosition( - PlayLoop->Ext2IntClock(recd_clock / 48 * 48)); + mpPlayLoop->Ext2IntClock(recd_clock / 48 * 48)); } return recd_clock; } Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/Audio.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -203,7 +203,7 @@ adjust_audio_length = 1; has_changed = false; spl_dialog = 0; - glb_dialog = 0; + mpGlobalSettingsDialog = 0; is_playing = 0; softsync = 1; dirty = 0; @@ -744,7 +744,7 @@ if (set.is_playing) return; wxBeginBusyCursor(); - set.glb_dialog = 0; + set.mpGlobalSettingsDialog = 0; speed = atol(speedstr); set.SetSpeed(speed); set.SetChannels(stereo ? 2 : 1); @@ -782,7 +782,7 @@ } void OnCancel() { - set.glb_dialog = 0; + set.mpGlobalSettingsDialog = 0; wxForm::OnCancel(); } private: @@ -811,16 +811,16 @@ return; } - if (glb_dialog == 0) + if (mpGlobalSettingsDialog == 0) { #ifdef OBSOLETE - glb_dialog = new wxDialogBox(gpTrackWindow, "Audio Settings", false); + mpGlobalSettingsDialog = new wxDialogBox(gpTrackWindow, "Audio Settings", false); tAudioGloblForm *form = new tAudioGloblForm(*this); - form->AssociatePanel(glb_dialog); - glb_dialog->Fit(); + form->AssociatePanel(mpGlobalSettingsDialog); + mpGlobalSettingsDialog->Fit(); #endif // OBSOLETE } - glb_dialog->Show(true); + mpGlobalSettingsDialog->Show(true); } //----------------------------------------------------------------------------- @@ -898,12 +898,12 @@ // delete selection #ifdef OBSOLETE - JZSong *song = gpProject->Song; + JZSong* pSong = gpProject->mpSong; #endif const JZRecordingInfo* info = gpProject->GetRecInfo(); JZTrack* track = info->mpTrack; #ifdef OBSOLETE - song->NewUndoBuffer(); + pSong->NewUndoBuffer(); #endif tEventIterator iter(info->mpTrack); JZEvent *e = iter.Range(frc, toc); @@ -1286,9 +1286,9 @@ //----------------------------------------------------------------------------- void tSampleSet::SamplesDlg() { - if (glb_dialog) + if (mpGlobalSettingsDialog) { - glb_dialog->Show(true); + mpGlobalSettingsDialog->Show(true); return; } if (spl_dialog == 0) @@ -1363,7 +1363,7 @@ return 1; case ID_AUDIO_NEW: - if (spl_dialog == 0 && glb_dialog == 0) + if (spl_dialog == 0 && mpGlobalSettingsDialog == 0) { if (wxMessageBox("Clear Sample Set?", "Confirm", wxYES_NO) == wxNO) { Modified: trunk/jazz/src/Audio.h =================================================================== --- trunk/jazz/src/Audio.h 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/Audio.h 2010-04-05 03:53:42 UTC (rev 744) @@ -221,6 +221,8 @@ class tSamplesDlg; +//***************************************************************************** +//***************************************************************************** class tSampleSet { private: @@ -368,6 +370,8 @@ return *samples[i]; } + void GlobalSettingsDlg(); + protected: long SampleSize(long num_samples) @@ -375,6 +379,15 @@ return channels * (bits == 8 ? 1L : 2L) * num_samples; } + long BufferClock(int i) const + { + return (long)(start_clock + i * clocks_per_buffer); + } + + void SamplesDlg(); + + protected: + long speed; // samples / second int channels; // mono = 1, stereo = 2 int bits; // must be 16! @@ -389,7 +402,6 @@ int event_index; - unsigned int bufbytes; // buffer size in byte unsigned int bufshorts; // buffer size in short tAudioBuffer *buffers[BUFCOUNT]; // all the audio buffers @@ -399,20 +411,18 @@ // return the start clock for i-th free buffer long buffers_written; // for computing buffers clock - long BufferClock(int i) const - { - return (long)(start_clock + i * clocks_per_buffer); - } - void GlobalSettingsDlg(); - void SamplesDlg(); - wxDialog *glb_dialog; - tSamplesDlg *spl_dialog; + wxDialog* mpGlobalSettingsDialog; + tSamplesDlg* spl_dialog; - tEventArray *events; + tEventArray* events; - enum { MAXPOLY = 100 }; - tSampleVoice * voices[MAXPOLY]; + enum + { + MAXPOLY = 100 + }; + + tSampleVoice* voices[MAXPOLY]; int num_voices; int adjust_audio_length; Modified: trunk/jazz/src/AudioDriver.cpp =================================================================== --- trunk/jazz/src/AudioDriver.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/AudioDriver.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -122,7 +122,7 @@ : tSeq2Player(pSong) { long dummy = 0; - AudioBuffer = new tEventArray(); + mpAudioBuffer = new tEventArray(); mInstalled = false; dummy = gpConfig->GetValue(C_EnableAudio); audio_enabled = dummy; @@ -171,9 +171,11 @@ tAudioPlayer::~tAudioPlayer() { delete mpListener; - delete AudioBuffer; + delete mpAudioBuffer; if (dev >= 0) + { close(dev); + } } @@ -194,16 +196,16 @@ return; } - long ticks_per_minute = Song->GetTicksPerQuarter() * Song->Speed(); - mSamples.ResetBuffers(AudioBuffer, start_clock, ticks_per_minute); + long ticks_per_minute = mpSong->GetTicksPerQuarter() * mpSong->Speed(); + mSamples.ResetBuffers(mpAudioBuffer, start_clock, ticks_per_minute); if (PlaybackMode()) { - mSamples.FillBuffers(OutClock); + mSamples.FillBuffers(mOutClock); } audio_bytes = 0; midi_clock = 0; - midi_speed = Song->Speed(); + midi_speed = mpSong->Speed(); curr_speed = midi_speed; OpenDsp(); @@ -351,7 +353,7 @@ WriteSamples(); // here it may hang when swapping in pages - mSamples.FillBuffers(OutClock); + mSamples.FillBuffers(mOutClock); WriteSamples(); } Modified: trunk/jazz/src/ControlEdit.cpp =================================================================== --- trunk/jazz/src/ControlEdit.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/ControlEdit.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -25,7 +25,7 @@ #include "EventWindow.h" #include "Filter.h" #include "PianoWindow.h" -#include "Song.h" +#include "Project.h" #include "Track.h" #include <wx/button.h> @@ -259,7 +259,7 @@ void tCtrlEditBase::OnApply() { wxBeginBusyCursor(); - mpPianoWindow->GetSong()->NewUndoBuffer(); + mpPianoWindow->GetProject()->NewUndoBuffer(); // delete old events, but skip clock 0 to preserve track defaults: // (dirty but might work...) tEventIterator iter(track); @@ -383,7 +383,7 @@ // av: called by tArrayEdit::OnPaint void tCtrlEditBase::DrawBars(wxDC* dc) { - JZBarInfo BarInfo(*mpPianoWindow->GetSong()); + JZBarInfo BarInfo(*mpPianoWindow->GetProject()); BarInfo.SetClock(from_clock); long gclk,x; int ii; @@ -541,7 +541,7 @@ static long from_clk, to_clk; wxBeginBusyCursor(); - mpPianoWindow->GetSong()->NewUndoBuffer(); + mpPianoWindow->GetProject()->NewUndoBuffer(); tEventIterator iter(track); @@ -656,7 +656,7 @@ } wxBeginBusyCursor(); - mpPianoWindow->GetSong()->NewUndoBuffer(); + mpPianoWindow->GetProject()->NewUndoBuffer(); tEventIterator iter(track); @@ -817,7 +817,7 @@ void tChannelAfterEdit::OnApply() { wxBeginBusyCursor(); - mpPianoWindow->GetSong()->NewUndoBuffer(); + mpPianoWindow->GetProject()->NewUndoBuffer(); // delete old events, but skip clock 0 to preserve track defaults: // (dirty but might work...) Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/Dialogs.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -273,7 +273,7 @@ tEventDlg::tEventDlg(JZEvent *e, JZPianoWindow* w, JZTrack *t) : tPropertyListDlg( "Event" ), - ClockDlg(w->GetSong(), "Time ", e->GetClock()) + ClockDlg(w->GetProject(), "Time ", e->GetClock()) { Win = w; Track = t; @@ -954,7 +954,10 @@ case StatSetTempo: str = "Set Tempo (for track 0)"; - dlg = new tSetTempoDlg(e->IsSetTempo(), pPianoWindow, pPianoWindow->GetSong()->GetTrack(0) ); + dlg = new tSetTempoDlg( + e->IsSetTempo(), + pPianoWindow, + pPianoWindow->GetProject()->GetTrack(0)); break; case StatSysEx: @@ -1024,8 +1027,8 @@ bool tMeterChangeDlg::OnClose() { - BarNr += mpEventWindow->GetSong()->GetIntroLength(); - mpEventWindow->GetSong()->SetMeterChange(BarNr, Numerator, Denomiator); + BarNr += mpEventWindow->GetProject()->GetIntroLength(); + mpEventWindow->GetProject()->SetMeterChange(BarNr, Numerator, Denomiator); mpEventWindow->Refresh(); mpEventWindow->FinishMeterEdit(); return false; Modified: trunk/jazz/src/EventWindow.cpp =================================================================== --- trunk/jazz/src/EventWindow.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/EventWindow.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -35,9 +35,9 @@ #include "Dialogs.h" #include "EventFrame.h" #include "Filter.h" +#include "Help.h" #include "MouseAction.h" -#include "Song.h" -#include "Help.h" +#include "Project.h" #include "ProjectManager.h" #include <wx/dc.h> @@ -59,7 +59,7 @@ //----------------------------------------------------------------------------- JZEventWindow::JZEventWindow( wxFrame* pParent, - JZSong* pSong, + JZProject* pProject, const wxPoint& Position, const wxSize& Size) : wxWindow( @@ -71,7 +71,7 @@ mpSnapSel(0), mpFilter(0), mpMouseAction(0), - mpSong(pSong), + mpProject(pProject), mpGreyColor(0), mpGreyBrush(0), mClockTicsPerPixel(36), @@ -95,7 +95,7 @@ { mpSnapSel = new JZSnapSelection(this); - mpFilter = new JZFilter(mpSong); + mpFilter = new JZFilter(mpProject); #ifdef __WXMSW__ mpGreyColor = new wxColor(192, 192, 192); @@ -181,7 +181,7 @@ if (QuantizeDialog.ShowModal() == wxID_OK) { - int Step = mpSong->GetTicksPerQuarter() * 4 / QuantizationStep; + int Step = mpProject->GetTicksPerQuarter() * 4 / QuantizationStep; tCmdQuantize QuantizeCommand( mpFilter, @@ -397,7 +397,7 @@ int& EventHeight) const { int TotalClockTics = - mpSong->GetMaxQuarters() * mpSong->GetTicksPerQuarter(); + mpProject->GetMaxQuarters() * mpProject->GetTicksPerQuarter(); EventWidth = TotalClockTics / mClockTicsPerPixel; EventHeight = 127 * mTrackHeight; } @@ -469,7 +469,7 @@ int JZEventWindow::x2BarClock(int x, int Next) { int Clock = x2Clock(x); - JZBarInfo BarInfo(*mpSong); + JZBarInfo BarInfo(*mpProject); BarInfo.SetClock(Clock); while (Next--) { Modified: trunk/jazz/src/EventWindow.h =================================================================== --- trunk/jazz/src/EventWindow.h 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/EventWindow.h 2010-04-05 03:53:42 UTC (rev 744) @@ -28,7 +28,7 @@ class JZFilter; class JZMouseAction; class JZSnapSelection; -class JZSong; +class JZProject; class wxDialog; //***************************************************************************** @@ -42,14 +42,14 @@ JZEventWindow( wxFrame* pParent, - JZSong* pSong, + JZProject* pProject, const wxPoint& Position = wxDefaultPosition, const wxSize& Size = wxDefaultSize); virtual ~JZEventWindow(); // WARNING: non-constant access. - JZSong* GetSong() const; + JZProject* GetProject() const; bool AreEventsSelected(); @@ -130,7 +130,7 @@ protected: - JZSong* mpSong; + JZProject* mpProject; wxColor* mpGreyColor; wxBrush* mpGreyBrush; @@ -162,9 +162,9 @@ // WARNING: non-constant access. //----------------------------------------------------------------------------- inline -JZSong* JZEventWindow::GetSong() const +JZProject* JZEventWindow::GetProject() const { - return mpSong; + return mpProject; } #endif // !defined(JZ_EVENTWINDOW_H) Modified: trunk/jazz/src/PianoFrame.cpp =================================================================== --- trunk/jazz/src/PianoFrame.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/PianoFrame.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -210,7 +210,7 @@ JZPianoFrame::JZPianoFrame( wxWindow* pParent, const wxString& Title, - JZSong* pSong, + JZProject* pProject, const wxPoint& Position, const wxSize& Size) : wxFrame( @@ -223,7 +223,7 @@ mpPianoWindow(0), // mpFileMenu(0), // mpEditMenu(0) - mpSong(pSong), + mpProject(pProject), mpToolBar(0) { CreateToolBar(); @@ -242,7 +242,7 @@ mTrackIndex = 0; mpToolBar->ToggleTool(ID_SNAP_16, TRUE); - mpPianoWindow = new JZPianoWindow(this, pSong); + mpPianoWindow = new JZPianoWindow(this, pProject); } //----------------------------------------------------------------------------- Modified: trunk/jazz/src/PianoFrame.h =================================================================== --- trunk/jazz/src/PianoFrame.h 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/PianoFrame.h 2010-04-05 03:53:42 UTC (rev 744) @@ -29,11 +29,11 @@ #include <wx/frame.h> class JZGuitarFrame; -class JZSong; +class JZPianoWindow; +class JZProject; class JZToolBar; +class JZTrack; class tCtrlEditBase; -class JZTrack; -class JZPianoWindow; //***************************************************************************** //***************************************************************************** @@ -46,7 +46,7 @@ JZPianoFrame( wxWindow* pParent, const wxString& Title, - JZSong* pSong, + JZProject* pProject, const wxPoint& Position = wxDefaultPosition, const wxSize& Size = wxDefaultSize); @@ -132,7 +132,7 @@ JZPianoWindow* mpPianoWindow; int mClockTicsPerPixel; - JZSong* mpSong; + JZProject* mpProject; wxDialog* mpDialogBox; wxDialog* MixerForm; Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/PianoWindow.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -241,7 +241,7 @@ Win = pPianoWindow; // BUG FIX: undo/redo - Win->GetSong()->NewUndoBuffer(); + Win->GetProject()->NewUndoBuffer(); wxClientDC Dc(Win); @@ -390,7 +390,7 @@ Win = pPianoWindow; // BUG FIX: undo/redo - Win->GetSong()->NewUndoBuffer(); + Win->GetProject()->NewUndoBuffer(); // wxClientDC Dc(Win); Win->PrepareDC(Dc); @@ -479,7 +479,7 @@ mpKeyOn = pKeyOn; // BUG FIX: undo/redo - Win->GetSong()->NewUndoBuffer(); + Win->GetProject()->NewUndoBuffer(); // wxClientDC Dc(Win); Dc.SetFont(*(Win->GetFixedFont())); @@ -639,10 +639,10 @@ //----------------------------------------------------------------------------- JZPianoWindow::JZPianoWindow( JZPianoFrame* pPianoFrame, - JZSong* pSong, + JZProject* pProject, const wxPoint& Position, const wxSize& Size) - : JZEventWindow(pPianoFrame, pSong, Position, Size), + : JZEventWindow(pPianoFrame, pProject, Position, Size), mpPianoFrame(pPianoFrame), mPlayClock(-1), mSnapCount(0), @@ -679,7 +679,7 @@ InitColors(); - mpTrack = mpSong->GetTrack(mTrackIndex); + mpTrack = mpProject->GetTrack(mTrackIndex); mFontSize = mPianoFontSizes[1]; // Must be an entry in the array. @@ -823,7 +823,7 @@ mPianoX = 0; - JZBarInfo BarInfo(*mpSong); + JZBarInfo BarInfo(*mpProject); //DEBUG cout //DEBUG << "mLeftInfoWidth: " << mLeftInfoWidth << '\n' @@ -892,7 +892,7 @@ BarInfo.SetClock(mFromClock); int StopClk = x2Clock(mCanvasWidth); int clk = BarInfo.GetClock(); - int intro = mpSong->GetIntroLength(); + int intro = mpProject->GetIntroLength(); while (clk < StopClk) { clk = BarInfo.GetClock(); @@ -1010,9 +1010,9 @@ if (mVisibleAllTracks) { - for (int i = 0; i < mpSong->GetTrackCount(); ++i) + for (int i = 0; i < mpProject->GetTrackCount(); ++i) { - JZTrack* pTrack = mpSong->GetTrack(i); + JZTrack* pTrack = mpProject->GetTrack(i); if (pTrack != mpTrack && IsVisible(pTrack)) { DrawEvents(LocalDc, pTrack, StatKeyOn, wxLIGHT_GREY_BRUSH, TRUE); @@ -1173,7 +1173,7 @@ } return true; case WXK_DOWN: - if (mTrackIndex < mpSong->GetTrackCount() - 1) + if (mTrackIndex < mpProject->GetTrackCount() - 1) { ++mTrackIndex; NewPosition(mTrackIndex, -1); @@ -1204,7 +1204,7 @@ if (TrackIndex >= 0) { mTrackIndex = TrackIndex; - mpTrack = mpSong->GetTrack(mTrackIndex); + mpTrack = mpProject->GetTrack(mTrackIndex); mpPianoFrame->SetTitle(mpTrack->GetName()); SetYScrollPosition(TrackIndex2y(mFromLines[mTrackIndex])); @@ -1732,7 +1732,7 @@ if (action) { - if (!gpMidiPlayer->Playing) + if (!gpMidiPlayer->IsPlaying()) { int Clock, LoopClock; if (action == MA_CYCLE) @@ -2000,7 +2000,7 @@ // Avoid permenent redraws when end of scroll range is reached. if ( Clock > mFromClock && - mToClock >= mpSong->GetMaxQuarters() * mpSong->GetTicksPerQuarter()) + mToClock >= mpProject->GetMaxQuarters() * mpProject->GetTicksPerQuarter()) { return; } @@ -2259,9 +2259,9 @@ else if (mVisibleAllTracks) { // event not found, maybe change to another Track - for (int i = 0; i < mpSong->GetTrackCount(); ++i) + for (int i = 0; i < mpProject->GetTrackCount(); ++i) { - JZTrack* pTrack = mpSong->GetTrack(i); + JZTrack* pTrack = mpProject->GetTrack(i); if (IsVisible(pTrack) && FindEvent(pTrack, Clock, Pitch)) { NewPosition(i, -1); @@ -2387,7 +2387,7 @@ //----------------------------------------------------------------------------- int JZPianoWindow::SnapClocks() { - int Clock = mpSong->GetTicksPerQuarter() * 4 / mSnapDenomiator; + int Clock = mpProject->GetTicksPerQuarter() * 4 / mSnapDenomiator; if (Clock < 1) { return 1; @@ -2814,7 +2814,7 @@ //----------------------------------------------------------------------------- void JZPianoWindow::Redo() { - mpSong->Redo(); + mpProject->Redo(); Refresh(); if (mpCtrlEdit && mpTrack >= 0) { @@ -2827,7 +2827,7 @@ //----------------------------------------------------------------------------- void JZPianoWindow::Undo() { - mpSong->Undo(); + mpProject->Undo(); Refresh(); if (mpCtrlEdit && mpTrack >= 0) { @@ -3024,7 +3024,7 @@ return; } - mpSong->NewUndoBuffer(); + mpProject->NewUndoBuffer(); mPasteBuffer.Clear(); mPasteBuffer.Put(pEvent->Copy()); @@ -3097,7 +3097,7 @@ Pitch = -1; } - mpSong->NewUndoBuffer(); + mpProject->NewUndoBuffer(); tEventIterator Iterator(&mPasteBuffer); JZEvent* pEvent = Iterator.First(); if (pEvent) Modified: trunk/jazz/src/PianoWindow.h =================================================================== --- trunk/jazz/src/PianoWindow.h 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/PianoWindow.h 2010-04-05 03:53:42 UTC (rev 744) @@ -30,12 +30,12 @@ #include <wx/brush.h> +class tCtrlEditBase; +class JZEvent; +class JZFilter; class JZPianoFrame; -class JZSong; +class JZProject; class JZTrack; -class JZEvent; -class JZFilter; -class tCtrlEditBase; //***************************************************************************** //***************************************************************************** @@ -70,7 +70,7 @@ JZPianoWindow( JZPianoFrame* pFrame, - JZSong* pSong, + JZProject* pProject, const wxPoint& Position = wxDefaultPosition, const wxSize& Size = wxDefaultSize); Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/Player.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -182,36 +182,125 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- JZPlayer::JZPlayer(JZSong* pSong) - : mSamples(pSong->GetTicksPerQuarter() * pSong->Speed()) + : mOutClock(0), + mpPlayLoop(0), + mPollMillisec(200), + mpRecordingInfo(0), + mPlaying(false), + mpSong(pSong), + mpAudioBuffer(0), + mSamples(pSong->GetTicksPerQuarter() * pSong->Speed()) { DummyDeviceList.Add("default"); - poll_millisec = 200; // default - Song = pSong; - OutClock = 0; - Playing = false; - PlayLoop = new tPlayLoop(); - AudioBuffer = 0; - mpRecordingInfo = 0; + mpPlayLoop = new tPlayLoop(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- JZPlayer::~JZPlayer() { - delete PlayLoop; + delete mpPlayLoop; mPlayBuffer.Clear(); mRecdBuffer.Clear(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZPlayer::ShowError() +void JZPlayer::Notify() { - wxMessageBox("could not install driver", "Error", wxOK); + // called by timer + long Now = GetRealTimeClock(); + +#ifdef DEBUG_PLAYER_NOTIFY + cout << "JZPlayer::Notify " << Now << endl; +#endif // DEBUG_PLAYER_NOTIFY + if (Now < 0) + { + return; + } + + // time to put more events + if (Now >= (mOutClock - ADVANCE_PLAY)) + { +#ifdef DEBUG_PLAYER_NOTIFY + cout << "*** Notify: more events to playbuffer" << endl; +#endif // DEBUG_PLAYER_NOTIFY + + mpPlayLoop->PrepareOutput( + &mPlayBuffer, + mpSong, + mOutClock, + Now + DELTACLOCK, + 0); + if (mpAudioBuffer) + { + mpPlayLoop->PrepareOutput( + mpAudioBuffer, + mpSong, + mOutClock, + Now + DELTACLOCK, + 1); + } + mOutClock = Now + DELTACLOCK; + mPlayBuffer.Length2Keyoff(); + } + + // optimization: + // + // if (there are some events to be played) + // send them to driver + // else + // tell the driver that there is nothing to do at the moment + if (mPlayBuffer.nEvents && mPlayBuffer.Events[0]->GetClock() < mOutClock) + { + FlushToDevice(); + } + else + { + // Does nothing unless mOutClock has changed. + OutBreak(); + } } //----------------------------------------------------------------------------- +// Description: +// Try to send all events up to mOutClock to device. //----------------------------------------------------------------------------- +void JZPlayer::FlushToDevice() +{ + int BufferFull = 0; + + tEventIterator Iterator(&mPlayBuffer); + JZEvent* pEvent = Iterator.Range(0, mOutClock); + while (!BufferFull && pEvent) + { + if (OutEvent(pEvent) != 0) + BufferFull = 1; + else + { + pEvent->Kill(); + pEvent = Iterator.Next(); + } + } + + if (!BufferFull) + OutBreak(); + mPlayBuffer.Cleanup(0); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPlayer::OutNow(JZTrack *t, tParam *r) +{ + OutNow(t, &r->mMsb); + OutNow(t, &r->mLsb); + OutNow(t, &r->mDataMsb); + OutNow(t, &r->mResetMsb); + OutNow(t, &r->mResetLsb); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZPlayer::StartPlay(long Clock, long LoopClock, int Continue) { #ifdef DEBUG_PLAYER_STARTPLAY @@ -222,19 +311,19 @@ if (LoopClock > 0) { - PlayLoop->Set(Clock, LoopClock); + mpPlayLoop->Set(Clock, LoopClock); } else { - PlayLoop->Reset(); + mpPlayLoop->Reset(); } - Clock = PlayLoop->Int2ExtClock(Clock); + Clock = mpPlayLoop->Int2ExtClock(Clock); mPlayBuffer.Clear(); mRecdBuffer.Clear(); - if (AudioBuffer) + if (mpAudioBuffer) { - AudioBuffer->Clear(); + mpAudioBuffer->Clear(); } JZTrack *t; @@ -246,16 +335,16 @@ ((Clock == 0) && (gpConfig->GetValue(C_SendSynthReset) == 1))) { // fixme: we should have different synths for each device - t = Song->GetTrack(0); + t = mpSong->GetTrack(0); JZEvent* mpResetEvent = gpSynth->CreateResetEvent(); OutNow(t, mpResetEvent); delete mpResetEvent; } // Send Volume, Pan, Chorus, etc - for (i = 0; i < Song->GetTrackCount(); ++i) + for (i = 0; i < mpSong->GetTrackCount(); ++i) { - t = Song->GetTrack(i); + t = mpSong->GetTrack(i); if (t->mpBank) { OutNow(t, t->mpBank); @@ -459,7 +548,7 @@ } // for } // if !Continue - t = Song->GetTrack(0); + t = mpSong->GetTrack(0); JZEvent* pEvent = t->GetCurrentTempo(Clock); if (pEvent) { @@ -481,23 +570,34 @@ gpConfig->GetValue(C_ThruInput), gpConfig->GetValue(C_ThruOutput)); - OutClock = Clock + FIRST_DELTACLOCK; + mOutClock = Clock + FIRST_DELTACLOCK; JZProjectManager::Instance()->NewPlayPosition( - PlayLoop->Ext2IntClock(Clock)); + mpPlayLoop->Ext2IntClock(Clock)); - PlayLoop->PrepareOutput(&mPlayBuffer, Song, Clock, Clock + FIRST_DELTACLOCK, 0); - if (AudioBuffer) + mpPlayLoop->PrepareOutput( + &mPlayBuffer, + mpSong, + Clock, + Clock + FIRST_DELTACLOCK, + 0); + + if (mpAudioBuffer) { - PlayLoop->PrepareOutput(AudioBuffer, Song, Clock, Clock + FIRST_DELTACLOCK, 1); + mpPlayLoop->PrepareOutput( + mpAudioBuffer, + mpSong, + Clock, + Clock + FIRST_DELTACLOCK, + 1); } mPlayBuffer.Length2Keyoff(); // Notify() has to be called very often because voxware // midi thru is done there - Start(poll_millisec); // start wxTimer + Start(mPollMillisec); // start wxTimer - Playing = true; + mPlaying = true; } //----------------------------------------------------------------------------- @@ -506,7 +606,7 @@ { // Stop the wxTimer. Stop(); - Playing = false; + mPlaying = false; long Clock = GetRealTimeClock(); @@ -514,9 +614,9 @@ int ii; tKeyOff pKeyOff(0, 0, 0); - for (ii = 0; ii < Song->GetTrackCount(); ii++) + for (ii = 0; ii < mpSong->GetTrackCount(); ii++) { - JZTrack *Track = Song->GetTrack(ii); + JZTrack *Track = mpSong->GetTrack(ii); if (Track) { tEventIterator Iterator(Track); @@ -543,80 +643,6 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZPlayer::Notify() -{ - // called by timer - long Now = GetRealTimeClock(); - -#ifdef DEBUG_PLAYER_NOTIFY - cout << "JZPlayer::Notify " << Now << endl; -#endif // DEBUG_PLAYER_NOTIFY - if (Now < 0) - { - return; - } - - // time to put more events - if (Now >= (OutClock - ADVANCE_PLAY)) - { -#ifdef DEBUG_PLAYER_NOTIFY - cout << "*** Notify: more events to playbuffer" << endl; -#endif // DEBUG_PLAYER_NOTIFY - - PlayLoop->PrepareOutput(&mPlayBuffer, Song, OutClock, Now + DELTACLOCK, 0); - if (AudioBuffer) - { - PlayLoop->PrepareOutput(AudioBuffer, Song, OutClock, Now + DELTACLOCK, 1); - } - OutClock = Now + DELTACLOCK; - mPlayBuffer.Length2Keyoff(); - } - - // optimization: - // - // if (there are some events to be played) - // send them to driver - // else - // tell the driver that there is nothing to do at the moment - if (mPlayBuffer.nEvents && mPlayBuffer.Events[0]->GetClock() < OutClock) - { - FlushToDevice(); - } - else - { - // Does nothing unless OutClock has changed. - OutBreak(); - } -} - -//----------------------------------------------------------------------------- -// Description: -// Try to send all events up to OutClock to device. -//----------------------------------------------------------------------------- -void JZPlayer::FlushToDevice() -{ - int BufferFull = 0; - - tEventIterator Iterator(&mPlayBuffer); - JZEvent* pEvent = Iterator.Range(0, OutClock); - while (!BufferFull && pEvent) - { - if (OutEvent(pEvent) != 0) - BufferFull = 1; - else - { - pEvent->Kill(); - pEvent = Iterator.Next(); - } - } - - if (!BufferFull) - OutBreak(); - mPlayBuffer.Cleanup(0); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- void JZPlayer::AllNotesOff(int Reset) { tControl NoteOff(0, 0, 0x78, 0); @@ -652,15 +678,18 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZPlayer::OutNow(JZTrack *t, tParam *r) +void JZPlayer::ShowError() { - OutNow(t, &r->mMsb); - OutNow(t, &r->mLsb); - OutNow(t, &r->mDataMsb); - OutNow(t, &r->mResetMsb); - OutNow(t, &r->mResetLsb); + wxMessageBox("could not install driver", "Error", wxOK); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPlayer::EditGlobalAudioSettings(wxWindow* pParent) +{ + mSamples.GlobalSettingsDlg(); +} + #ifdef DEV_MPU401 //***************************************************************************** @@ -671,7 +700,7 @@ tMpuPlayer::tMpuPlayer(JZSong* pSong) : JZPlayer(pSong) { - poll_millisec = 25; + mPollMillisec = 25; midinethost = getenv("MIDINETHOST"); if (!midinethost || !strlen(midinethost)) { @@ -736,7 +765,7 @@ //----------------------------------------------------------------------------- void tMpuPlayer::StartPlay(long IntClock, long LoopClock, int Continue) { - long ExtClock = PlayLoop->Int2ExtClock(IntClock); + long ExtClock = mpPlayLoop->Int2ExtClock(IntClock); char *play; int playsize; @@ -794,7 +823,7 @@ // Setup Timebase char timebase[2]; timebase[0] = CMD+1; - switch (Song->GetTicksPerQuarter()) + switch (mpSong->GetTicksPerQuarter()) { case 48: timebase[1] = 0xc2; break; case 72: timebase[1] = 0xc3; break; @@ -1004,13 +1033,14 @@ //----------------------------------------------------------------------------- void tMpuPlayer::OutBreak() { - // send a break to the driver starting at PlyBytes.GetClock() and ending at OutClock + // Send a break to the driver starting at PlyBytes.GetClock() and ending at + // mOutClock. if (!PlyBytes.WriteFile(dev)) { return; } - (void)OutBreak(OutClock); + (void)OutBreak(mOutClock); PlyBytes.WriteFile(dev); } @@ -1182,14 +1212,14 @@ if ((clock_to_host_counter % 32) == 0) { JZProjectManager::Instance()->NewPlayPosition( - PlayLoop->Ext2IntClock(playclock)); + mpPlayLoop->Ext2IntClock(playclock)); } #else // Update screen every 8'th note (120 ticks/beat). if ((clock_to_host_counter % 4) == 0) { JZProjectManager::Instance()->NewPlayPosition( - PlayLoop->Ext2IntClock(playclock)); + mpPlayLoop->Ext2IntClock(playclock)); } #endif FlushOutOfBand(playclock); @@ -1225,7 +1255,7 @@ case 3: gpMidiPlayer->StopPlay(); d1 = c; - ExtClock = (d0 + (128 * d1)) * (Song->GetTicksPerQuarter() / 4); + ExtClock = (d0 + (128 * d1)) * (mpSong->GetTicksPerQuarter() / 4); receiving_song_ptr = 0; d0 = d1 = 0; gpMidiPlayer->StartPlay(ExtClock, 0, 1); @@ -1330,7 +1360,7 @@ } if (pEvent) { - pEvent->Clock = PlayLoop->Ext2IntClock(pEvent->Clock); + pEvent->Clock = mpPlayLoop->Ext2IntClock(pEvent->Clock); mRecdBuffer.Put(pEvent); } } @@ -1464,8 +1494,8 @@ tSeq2Player::tSeq2Player(JZSong* pSong) : JZPlayer(pSong) { - // got to poll fast for midi thru - poll_millisec = 10; + // The code has to poll fast for MIDI thru. + mPollMillisec = 10; recd_clock = 0; play_clock = 0; @@ -1820,7 +1850,7 @@ //----------------------------------------------------------------------------- void tSeq2Player::OutBreak() { - OutBreak(OutClock); + OutBreak(mOutClock); seqbuf_dump(); } @@ -1877,7 +1907,7 @@ recd_clock = Clock; JZProjectManager::Instance()->NewPlayPosition( - PlayLoop->Ext2IntClock(Clock)); + mpPlayLoop->Ext2IntClock(Clock)); // send initial program changes, controller etc SEQ_START_TIMER(); @@ -1889,8 +1919,8 @@ seqbuf_dump(); // setup timebase and current speed - int time_base = Song->GetTicksPerQuarter(); - int cur_speed = Song->GetTrack(0)->GetCurrentSpeed(Clock); + int time_base = mpSong->GetTicksPerQuarter(); + int cur_speed = mpSong->GetTrack(0)->GetCurrentSpeed(Clock); if (ioctl(seqfd, SNDCTL_TMR_TIMEBASE, &time_base) < 0) perror("ioctl time_base"); if (ioctl(seqfd, SNDCTL_TMR_TEMPO, &cur_speed) < 0) @@ -1929,12 +1959,12 @@ } //----------------------------------------------------------------------------- -// try to send all events up to OutClock to device +// try to send all events up to mOutClock to device //----------------------------------------------------------------------------- void tSeq2Player::FlushToDevice() { tEventIterator Iterator(&mPlayBuffer); - JZEvent* pEvent = Iterator.Range(0, OutClock); + JZEvent* pEvent = Iterator.Range(0, mOutClock); if (pEvent) { do @@ -1946,7 +1976,7 @@ mPlayBuffer.Cleanup(0); } - OutBreak(OutClock); + OutBreak(mOutClock); seqbuf_dump(); } @@ -2054,7 +2084,7 @@ if (pEvent) { - pEvent->SetClock(PlayLoop->Ext2IntClock(recd_clock)); + pEvent->SetClock(mpPlayLoop->Ext2IntClock(recd_clock)); mRecdBuffer.Put(pEvent); pEvent = 0; } @@ -2063,7 +2093,7 @@ } JZProjectManager::Instance()->NewPlayPosition( - PlayLoop->Ext2IntClock(recd_clock/48 * 48)); + mpPlayLoop->Ext2IntClock(recd_clock/48 * 48)); return recd_clock; } Modified: trunk/jazz/src/Player.h =================================================================== --- trunk/jazz/src/Player.h 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/Player.h 2010-04-05 03:53:42 UTC (rev 744) @@ -40,40 +40,6 @@ //***************************************************************************** //***************************************************************************** -class tPlayLoop -{ - public: - - tPlayLoop(); - - void Set(long Start, long Stop); - - void Reset(); - - // external clock -> internal clock where - // external clock == physical clock - // internal clock == song position - long Ext2IntClock(long Clock); - - // the other way round - long Int2ExtClock(long Clock); - - void PrepareOutput( - tEventArray* pEventArray, - JZSong* pSong, - long ExtFr, - long ExtTo, - int mode = 0); - - private: - - long mStartClock; - - long mStopClock; -}; - -//***************************************************************************** -//***************************************************************************** enum tClockSource { CsInt = 0, @@ -131,38 +97,120 @@ //***************************************************************************** //***************************************************************************** -class JZPlayer : public wxTimer +class tPlayLoop { - protected: + public: - long OutClock; - tPlayLoop* PlayLoop; - // timer value for polling the record queue - int poll_millisec; - JZRecordingInfo* mpRecordingInfo; // 0 == not recording + tPlayLoop(); + void Set(long Start, long Stop); + void Reset(); + + // external clock -> internal clock where + // external clock == physical clock + // internal clock == song position + long Ext2IntClock(long Clock); + + // the other way round + long Int2ExtClock(long Clock); + + void PrepareOutput( + tEventArray* pEventArray, + JZSong* pSong, + long ExtFr, + long ExtTo, + int mode = 0); + + private: + + long mStartClock; + + long mStopClock; +}; + +//***************************************************************************** +//***************************************************************************** +class JZPlayer : public wxTimer +{ public: - bool Playing; // successful StartPlay + JZPlayer(JZSong* pSong); + virtual ~JZPlayer(); + + void Notify(); + + virtual void FlushToDevice(); + + // return 0 = ok, 1 = buffer full, try again later + virtual int OutEvent(JZEvent* pEvent) = 0; + + virtual void OutBreak() = 0; + + // Send event immediately ignoring the clock. + void OutNow(JZTrack *t, JZEvent* pEvent) + { + pEvent->SetDevice(t->GetDevice()); + OutNow(pEvent); + } + + void OutNow(int device, JZEvent* pEvent) + { + pEvent->SetDevice(device); + OutNow(pEvent); + } + + void OutNow(JZTrack* t, tParam* r); + + // what's played right now? + virtual long GetRealTimeClock() = 0; + + virtual void StartPlay(long Clock, long LoopClock = 0, int Continue = 0); + virtual void StopPlay(); + virtual void AllNotesOff(int Reset = 0); + + virtual void SetSoftThru(int on, int idev, int odev) + { + } + + virtual void SetHardThru(int on, int idev, int odev) + { + } + + virtual void InitMtcRec() + { + } + + virtual tMtcTime* FreezeMtcRec() + { + return 0; + } + // Tests if hardware found and successfully setup. virtual bool IsInstalled() = 0; // if unable to install, pop up a messagebox explaining why. virtual void ShowError(); - JZSong *Song; - tEventArray mPlayBuffer; - tEventArray mRecdBuffer; - void SetRecordInfo(JZRecordingInfo* inf) + const tEventArray& GetRecordBuffer() const { - mpRecordingInfo = inf; + return mRecdBuffer; } + void SetRecordInfo(JZRecordingInfo* pRecordingInfo) + { + mpRecordingInfo = pRecordingInfo; + } + + bool IsRecordBufferEmpty() const + { + return mRecdBuffer.IsEmpty(); + } + bool IsPlaying() const { - return Playing; + return mPlaying; } virtual int FindMidiDevice() @@ -170,24 +218,52 @@ return -1; } - virtual int SupportsMultipleDevices() { return 0; } - virtual tDeviceList & GetOutputDevices() { return DummyDeviceList; } - virtual tDeviceList & GetInputDevices() { return DummyDeviceList; } - virtual int GetThruInputDevice() { return 0; } - virtual int GetThruOutputDevice() { return 0; } + virtual int SupportsMultipleDevices() + { + return 0; + } + virtual tDeviceList& GetOutputDevices() + { + return DummyDeviceList; + } + virtual tDeviceList& GetInputDevices() + { + return DummyDeviceList; + } + virtual int GetThruInputDevice() + { + return 0; + } + virtual int GetThruOutputDevice() + { + return 0; + } // Audio stuff - virtual void StartAudio() {} - tEventArray *AudioBuffer; - virtual int GetAudioEnabled() const { return 0; } - virtual void SetAudioEnabled(int) { } - virtual void ListenAudio(int key, int start_stop_mode = 1) {} - virtual void ListenAudio(tSample &spl, long fr_smpl, long to_smpl) {} - virtual bool IsListening() const { return 0; } + virtual void StartAudio() + { + } + virtual int GetAudioEnabled() const + { + return 0; + } + virtual void SetAudioEnabled(int) + { + } + virtual void ListenAudio(int key, int start_stop_mode = 1) + { + } + virtual void ListenAudio(tSample &spl, long fr_smpl, long to_smpl) + { + } + virtual bool IsListening() const + { + return 0; + } virtual int OnMenuCommand(int id) { - if (Playing) + if (mPlaying) { return 0; } @@ -201,10 +277,12 @@ virtual void AdjustAudioLength(JZTrack *t) { - long ticks_per_minute = Song->GetTicksPerQuarter() * Song->Speed(); + long ticks_per_minute = mpSong->GetTicksPerQuarter() * mpSong->Speed(); mSamples.AdjustAudioLength(t, ticks_per_minute); } + void EditGlobalAudioSettings(wxWindow* pParent); + void EditSample(int key) { mSamples.Edit(key); @@ -222,66 +300,31 @@ protected: - tSampleSet mSamples; + virtual void OutNow(JZEvent* pEvent) = 0; - public: + protected: - JZPlayer(JZSong *song); + long mOutClock; - virtual ~JZPlayer(); + tPlayLoop* mpPlayLoop; - void Notify(); + // This is the timer value for polling the record queue. + int mPollMillisec; - virtual void FlushToDevice(); + // If this value is 0, then not recording. + JZRecordingInfo* mpRecordingInfo; - // return 0 = ok, 1 = buffer full, try again later - virtual int OutEvent(JZEvent* pEvent) = 0; + bool mPlaying; - virtual void OutBreak() = 0; + JZSong* mpSong; - // send event immediately ignoring clock - void OutNow(JZTrack *t, JZEvent* pEvent) - { - pEvent->SetDevice(t->GetDevice()); - OutNow(pEvent); - } + tEventArray mPlayBuffer; + tEventArray mRecdBuffer; - void OutNow(int device, JZEvent* pEvent) - { - pEvent->SetDevice(device); - OutNow(pEvent); - } + tEventArray* mpAudioBuffer; - void OutNow(JZTrack *t, tParam *r); + tSampleSet mSamples; - // what's played right now? - virtual long GetRealTimeClock() = 0; - - virtual void StartPlay(long Clock, long LoopClock = 0, int Continue = 0); - virtual void StopPlay(); - virtual void AllNotesOff(int Reset = 0); - - virtual void SetSoftThru(int on, int idev, int odev) - { - } - - virtual void SetHardThru(int on, int idev, int odev) - { - } - - virtual void InitMtcRec() - { - } - - virtual tMtcTime* FreezeMtcRec() - { - return 0; - } - - protected: - - virtual void OutNow(JZEvent* pEvent) = 0; - private: tDeviceList DummyDeviceList; @@ -576,7 +619,7 @@ public: friend class tOSSThru; - tSeq2Player(JZSong *song); + tSeq2Player(JZSong* pSong); virtual bool IsInstalled(); virtual ~tSeq2Player(); int OutEvent(JZEvent *e, int now); Modified: trunk/jazz/src/PortMidiPlayer.cpp =================================================================== --- trunk/jazz/src/PortMidiPlayer.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/PortMidiPlayer.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -227,7 +227,7 @@ void JZPortMidiPlayer::SetTempo(int bpm, int clock) { int t1 = Clock2Time(clock); - mTicksPerMinute = bpm * Song->GetTicksPerQuarter(); + mTicksPerMinute = bpm * mpSong->GetTicksPerQuarter(); int t2 = Clock2Time(clock); mStartTime += (t1 - t2); } @@ -378,7 +378,7 @@ mStartTime = Pt_Time() + 500; mStartClock = clock; - mTicksPerMinute = Song->GetTicksPerQuarter() * Song->Speed(); + mTicksPerMinute = mpSong->GetTicksPerQuarter() * mpSong->Speed(); JZPlayer::StartPlay(clock, loopClock, cont); } @@ -406,7 +406,7 @@ long t = Pt_Time(); gpTrackWindow->NewPlayPosition( - PlayLoop->Ext2IntClock(Time2Clock(t) / 48 * 48)); + mpPlayLoop->Ext2IntClock(Time2Clock(t) / 48 * 48)); return Time2Clock(t); } Modified: trunk/jazz/src/Project.cpp =================================================================== --- trunk/jazz/src/Project.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/Project.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -341,10 +341,8 @@ StartUpSong = mpConfig->GetStrValue(C_StartUpSong); } - FILE* pFd = fopen(StartUpSong.c_str(), "r"); - if (pFd) + if (wxFileName::IsFileReadable(StartUpSong.c_str())) { - fclose(pFd); JZStandardRead Io; Read(Io, StartUpSong.c_str()); } @@ -623,6 +621,13 @@ } //----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZProject::EditAudioGlobalSettings(wxWindow* pParent) +{ + mpMidiPlayer->EditGlobalAudioSettings(pParent); +} + +//----------------------------------------------------------------------------- // Description: // Sets the internal mpRecInfo, used for recording apparently. // JZProject will take ownership of this pointer, so don't delete it after Modified: trunk/jazz/src/Project.h =================================================================== --- trunk/jazz/src/Project.h 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/Project.h 2010-04-05 03:53:42 UTC (rev 744) @@ -23,14 +23,14 @@ #ifndef JZ_PROJECT_H #define JZ_PROJECT_H -class JZPlayer; -class JZSynth; -class JZFilter; - #include "Song.h" #include "Metronome.h" +class JZFilter; +class JZPlayer; class JZRecordingInfo; +class JZSynth; +class wxWindow; //***************************************************************************** // Description: @@ -156,6 +156,8 @@ // Sets RecInfo, JZProject takes ownership of this object void SetRecInfo(JZRecordingInfo* pRecInfo); + void EditAudioGlobalSettings(wxWindow* pParent); + JZPlayer* GetPlayer() { return mpMidiPlayer; Modified: trunk/jazz/src/ProjectManager.cpp =================================================================== --- trunk/jazz/src/ProjectManager.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/ProjectManager.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -66,7 +66,7 @@ mpTrackFrame = new JZTrackFrame( 0, "Jazz++", - gpSong, + gpProject, Position, Size); } @@ -96,7 +96,7 @@ mpPianoFrame = new JZPianoFrame( mpTrackFrame, "Piano", - gpSong, + gpProject, Position, Size); } Modified: trunk/jazz/src/Sample.h =================================================================== --- trunk/jazz/src/Sample.h 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/Sample.h 2010-04-05 03:53:42 UTC (rev 744) @@ -256,14 +256,19 @@ return length; } - int IsEmpty() const { + bool IsEmpty() const + { return length == 0; } - void SetExternal(int ext) { + + void SetExternal(int ext) + { external_flag = ext; //external_time = 0; } - int GetExternal() const { + + int GetExternal() const + { return external_flag; } Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/Track.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -1687,7 +1687,7 @@ return Events[nEvents - 1]->GetClock(); } -int tEventArray::IsEmpty() +bool tEventArray::IsEmpty() const { return nEvents == 0; } @@ -1999,8 +1999,13 @@ t->nEvents = 0; } - -void JZTrack::MergeRange(tEventArray *other, int FromClock, int ToClock, int Replace) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZTrack::MergeRange( + const tEventArray& Other, + int FromClock, + int ToClock, + int Replace) { // Erase destin if (Replace) @@ -2015,7 +2020,7 @@ } // Merge Recorded Events - tEventIterator Copy(other); + tEventIterator Copy(&Other); JZEvent* pEvent = Copy.Range(FromClock, ToClock); while (pEvent) { Modified: trunk/jazz/src/Track.h =================================================================== --- trunk/jazz/src/Track.h 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/Track.h 2010-04-05 03:53:42 UTC (rev 744) @@ -347,9 +347,9 @@ tDrumInstrumentParameter *NextElem( tDrumInstrumentParameter *cur ); void DelElem( int pit ); void Clear(); - int IsEmpty() + bool IsEmpty() const { - return( list == 0 ); + return list == 0; } private: @@ -524,7 +524,7 @@ void Write(JZWriteBase& Io); int GetLastClock() const; - int IsEmpty(); + bool IsEmpty() const; int GetFirstClock(); int State; // tsXXX @@ -586,11 +586,13 @@ } void Merge(tEventArray *other); + void MergeRange( - tEventArray *other, + const tEventArray& Other, int FromClock, int ToClock, int Replace = 0); + void Undo(); void Redo(); void NewUndoBuffer(); Modified: trunk/jazz/src/TrackFrame.cpp =================================================================== --- trunk/jazz/src/TrackFrame.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/TrackFrame.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -120,14 +120,16 @@ JZTrackFrame::JZTrackFrame( wxWindow* pParent, const wxString& Title, - JZSong* pSong, + JZProject* pProject, const wxPoint& Position, const wxSize& Size) - : JZEventFrame(pParent, Title, pSong, Position, Size), + : JZEventFrame(pParent, Title, pProject, Position, Size), mpToolBar(0), mpFileMenu(0), mpEditMenu(0), mpToolsMenu(0), + mpProject(pProject), + mpTrackWindow(0), mPreviousClock(0), mPreviouslyRecording(false) { @@ -137,7 +139,7 @@ mpTrackWindow = new JZTrackWindow( this, - pSong, + pProject, wxPoint(0, 0), wxSize(600, 120)); @@ -644,7 +646,7 @@ //----------------------------------------------------------------------------- void JZTrackFrame::OnAudioGlobalSettings(wxCommandEvent& Event) { -// mpTrackWindow->EditAudioGlobalSettings(*this); + mpProject->EditAudioGlobalSettings(this); } //----------------------------------------------------------------------------- Modified: trunk/jazz/src/TrackFrame.h =================================================================== --- trunk/jazz/src/TrackFrame.h 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/TrackFrame.h 2010-04-05 03:53:42 UTC (rev 744) @@ -28,7 +28,7 @@ #include "EventFrame.h" -class JZSong; +class JZProject; class JZToolBar; class JZTrackWindow; class JZPianoWindow; @@ -42,7 +42,7 @@ JZTrackFrame( wxWindow* pParent, const wxString& Title, - JZSong* pSong, + JZProject* pProject, const wxPoint& Position = wxDefaultPosition, const wxSize& Size = wxDefaultSize); @@ -116,6 +116,8 @@ wxMenu* mpToolsMenu; + JZProject* mpProject; + JZTrackWindow* mpTrackWindow; int mPreviousClock; Modified: trunk/jazz/src/TrackWindow.cpp =================================================================== --- trunk/jazz/src/TrackWindow.cpp 2010-04-04 20:30:59 UTC (rev 743) +++ trunk/jazz/src/TrackWindow.cpp 2010-04-05 03:53:42 UTC (rev 744) @@ -67,10 +67,10 @@ //----------------------------------------------------------------------------- JZTrackWindow::JZTrackWindow( wxFrame* pParent, - JZSong* pSong, + JZProject* pProject, const wxPoint& Position, const wxSize& Size) - : JZEventWindow(pParent, pSong, Position, Size), + : JZEventWindow(pParent, pProject, Position, Size), mPlayClock(-1), mUseColors(true), mNumberWidth(), @@ -177,7 +177,7 @@ // Avoid permanent redraws when end of scroll range is reached. if ( Clock > mFromClock && - mToClock >= mpSong->GetMaxQuarters() * mpSong->GetTicksPerQuarter()) + mToClock >= mpProject->GetMaxQuarters() * mpProject->GetTicksPerQuarter()) { return; } @@ -274,7 +274,7 @@ JZRectangle Rectangle( 0, y2yLine(Point.y + mScrolledY), - Clock2x(mpSong->GetMaxQuarters() * mpSong->GetTicksPerQuarter()) + + Clock2x(mpProject->GetMaxQuarters() * mpProject->GetTicksPerQuarter()) + mScrolledX, mTrackHeight); mpSnapSel->Select(Rectangle); @@ -618,9 +618,9 @@ DrawHorizontalLine(LocalDc, mEventsY); DrawHorizontalLine(LocalDc, mEventsY - 1); - if (mpSong) + if (mpProject) { - JZBarInfo BarInfo(*mpSong); + JZBarInfo BarInfo(*mpProject); //DEBUG cout //DEBUG << "mLeftInfoWidth: " << mLeftInfoWidth << '\n' @@ -1026,12 +1026,12 @@ //----------------------------------------------------------------------------- void JZTrackWindow::DrawEvents(wxDC& Dc) { - if (!mpSong) + if (!mpProject) { return; } - JZBarInfo BarInfo(*mpSong); + JZBarInfo BarInfo(*mpProject); Dc.SetClippingRegion(mEventsX, mEventsY, mEventsWidth, mEventsHeight); @@ -1220,7 +1220,7 @@ //----------------------------------------------------------------------------- JZTrack* JZTrackWindow::y2Track(int y) { - return mpSong->GetTrack(y2TrackIndex(y)); + return mpProject->GetTrack(y2TrackIndex(y)); } //----------------------------------------------------------------------------- @@ -1386,7 +1386,7 @@ gpProject->mStopTime = loop_clock; gpProject->Play(); - } //if(!Midi->Playing) + } else { gpProject->Stop(); @@ -1408,18 +1408,21 @@ } if ( !pRecInfo->mpTrack->GetAudioMode() && - !gpProject->GetPlayer()->mRecdBuffer.IsEmpty()) + !gpProject->GetPlayer()->IsRecordBufferEmpty()) { //int choice = wxMessageBox("Keep recorded events?", "You played", wxOK | wxCANCEL); //if (choice == wxOK) { wxBeginBusyCursor(); + gpProject->NewUndoBuffer(); + pRecInfo... [truncated message content] |