From: <pst...@us...> - 2010-07-12 01:22:05
|
Revision: 790 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=790&view=rev Author: pstieber Date: 2010-07-12 01:21:59 +0000 (Mon, 12 Jul 2010) Log Message: ----------- 1. Added a new audio settings dialog. I added the controls, but it isn't functional. 2. Reordered includes, removed an unused macro, and updated the tSampleVoice class comment header in Audio.cpp. 3. Changed speed to mSamplingRate in tSampleSet and renamed the accessors and mutators accordingly. 4. Changed channels to mChannelCount in tSampleSet and renamed the accessors and mutators accordingly. 5. Changed GetAudioEnabled and SetAudioEnabled to use bool instead of int. 3. Modified Paths: -------------- trunk/jazz/src/Audio.cpp trunk/jazz/src/Audio.h trunk/jazz/src/Makefile.am trunk/jazz/src/Player.h trunk/jazz/src/Sample.cpp trunk/jazz/src/Sample.h trunk/jazz/src/SampleCommand.cpp trunk/jazz/src/SampleDialog.cpp trunk/jazz/src/SampleWindow.cpp trunk/jazz/src/Signal2.cpp trunk/jazz/src/Signal2.h trunk/jazz/src/mswin/WindowsAudioInterface.cpp trunk/jazz/src/mswin/WindowsAudioInterface.h trunk/jazz/vc9/JazzPlusPlus-VC9.vcproj Added Paths: ----------- trunk/jazz/src/Dialogs/AudioSettingsDialog.cpp trunk/jazz/src/Dialogs/AudioSettingsDialog.h Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/Audio.cpp 2010-07-12 01:21:59 UTC (rev 790) @@ -22,22 +22,23 @@ #include "Audio.h" +#include "Dialogs/AudioSettingsDialog.h" #include "Dialogs/SamplesDialog.h" -#include "Sample.h" #include "Events.h" -#include "RecordingInfo.h" -#include "Track.h" +#include "FileSelector.h" +#include "FindFile.h" #include "Globals.h" +#include "Help.h" #include "Player.h" -#include "TrackFrame.h" -#include "TrackWindow.h" -#include "SampleWindow.h" #include "Random.h" -#include "FindFile.h" -#include "FileSelector.h" -#include "StringReadWrite.h" -#include "Help.h" +#include "RecordingInfo.h" #include "Resources.h" +#include "Sample.h" +#include "SampleWindow.h" +#include "StringReadWrite.h" +#include "Track.h" +#include "TrackFrame.h" +#include "TrackWindow.h" #include <wx/filename.h> #include <wx/listbox.h> @@ -56,18 +57,17 @@ using namespace std; -#define db(a) cout << #a << " = " << a << endl - //***************************************************************************** +// Description: +// This is the sample voice class declaration. This class is activated via a +// MIDI note on signal. The class copies data from a tSample object to the +// output buffer as needed by the driver. //***************************************************************************** class tSampleVoice { - // Activated on note on. Copies data from a tSample object to the output - // buffer as needed by the driver. - public: - tSampleVoice(tSampleSet &s) + tSampleVoice(tSampleSet& s) : set(s) { } @@ -189,11 +189,10 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- tSampleSet::tSampleSet(long tpm) - : speed(22050), - channels(1), + : mSamplingRate(22050), + mChannelCount(1), bits(16), // dont change!! softsync(1), - mpGlobalSettingsDialog(0), mpSampleDialog(0), mDefaultFileName("noname.spl"), mRecordFileName("noname.wav") @@ -291,7 +290,7 @@ ifstream Is(FileName.c_str()); int Version; - Is >> Version >> speed >> channels >> softsync; + Is >> Version >> mSamplingRate >> mChannelCount >> softsync; while (Is) { int key, pan, vol, pitch; @@ -361,7 +360,9 @@ int tSampleSet::Save(const wxString& FileName) { ofstream Ofs(FileName.c_str()); - Ofs << 1 << ' ' << speed << ' ' << channels << ' ' << softsync << endl; + Ofs + << 1 << ' ' << mSamplingRate << ' ' << mChannelCount << ' ' << softsync + << endl; for (int i = 0; i < eSampleCount; i++) { tSample* pSample = mSamples[i]; @@ -518,8 +519,8 @@ } //----------------------------------------------------------------------------- -// returns the number of buffers containing sound. Fills as many -// buffers as possible, the last buffers may contain silence only. +// Returns the number of buffers containing sound. Fills as many buffers as +// possible, the last buffers may contain silence only. //----------------------------------------------------------------------------- int tSampleSet::PrepareListen(tSample *spl, long fr_smpl, long to_smpl) { @@ -684,9 +685,6 @@ }; #endif -// ----------------------------------------------------------------- -// ------------------------ global settings ------------------------ -// ----------------------------------------------------------------- #ifdef OBSOLETE class tAudioGloblForm : public wxForm @@ -694,7 +692,7 @@ public: tAudioGloblForm(tSampleSet &s) : wxForm( USED_WXFORM_BUTTONS ), - set(s) + mSampleSet(s) { ossbug1 = gpConfig->GetValue(C_OssBug1); @@ -709,7 +707,7 @@ "44100", 0 }; - speed = set.GetSpeed(); + speed = mSampleSet.GetSamplingRate(); speedstr = 0; for (int i = 0; speedtxt[i]; i++) { @@ -725,8 +723,8 @@ } enable = gpMidiPlayer->GetAudioEnabled(); - stereo = (set.GetChannels() == 2); - softsync = set.GetSoftSync(); + stereo = (mSampleSet.GetChannelCount() == 2); + softsync = mSampleSet.GetSoftSync(); Add(wxMakeFormBool("Enable Audio", &enable)); Add(wxMakeFormNewLine()); @@ -756,14 +754,14 @@ void OnOk() { - if (set.is_playing) + if (mSampleSet.is_playing) return; wxBeginBusyCursor(); - set.mpGlobalSettingsDialog = 0; + mSampleSet.mpGlobalSettingsDialog = 0; speed = atol(speedstr); - set.SetSpeed(speed); - set.SetChannels(stereo ? 2 : 1); - set.SetSoftSync(softsync); + mSampleSet.SetSamplingRate(speed); + mSampleSet.SetChannelCount(stereo ? 2 : 1); + mSampleSet.SetSoftSync(softsync); gpMidiPlayer->SetAudioEnabled(enable); if (gpConfig->GetValue(C_EnableAudio) != enable) @@ -791,17 +789,17 @@ } if (enable) - set.ReloadSamples(); + mSampleSet.ReloadSamples(); wxEndBusyCursor(); wxForm::OnOk(); } void OnCancel() { - set.mpGlobalSettingsDialog = 0; + mSampleSet.mpGlobalSettingsDialog = 0; wxForm::OnCancel(); } private: - tSampleSet &set; + tSampleSet& mSampleSet; wxList strlist; long speed; @@ -826,16 +824,8 @@ return; } - if (mpGlobalSettingsDialog == 0) - { - mpGlobalSettingsDialog = new wxDialog(pParent, wxID_ANY, "Audio Settings"); -#ifdef OBSOLETE - tAudioGloblForm *form = new tAudioGloblForm(*this); - form->AssociatePanel(mpGlobalSettingsDialog); - mpGlobalSettingsDialog->Fit(); -#endif // OBSOLETE - } - mpGlobalSettingsDialog->Show(true); + JZAudioSettingsDialog AudioSettingsDialog(pParent, *this); + AudioSettingsDialog.ShowModal(); } //----------------------------------------------------------------------------- @@ -896,7 +886,7 @@ //----------------------------------------------------------------------------- void tSampleSet::ClearSampleSet(wxWindow* pParent) { - if (mpSampleDialog == 0 && mpGlobalSettingsDialog == 0) + if (mpSampleDialog == 0) { if (wxMessageBox("Clear Sample Set?", "Confirm", wxYES_NO) == wxNO) { @@ -1031,11 +1021,11 @@ wh.sub_chunk = FMT; wh.data_chunk = DATA; wh.format = PCM_CODE; - wh.modus = channels; + wh.modus = mChannelCount; wh.sc_len = 16; - wh.sample_fq = speed; + wh.sample_fq = mSamplingRate; wh.bit_p_spl = bits; - wh.byte_p_spl = channels * (bits > 8 ? 2 : 1); + wh.byte_p_spl = mChannelCount * (bits > 8 ? 2 : 1); wh.byte_p_sec = wh.byte_p_spl * wh.sample_fq; @@ -1386,11 +1376,6 @@ //----------------------------------------------------------------------------- void tSampleSet::SamplesDlg() { - if (mpGlobalSettingsDialog) - { - mpGlobalSettingsDialog->Show(true); - return; - } if (mpSampleDialog == 0) { mpSampleDialog = new JZSamplesDialog(gpTrackWindow, *this); Modified: trunk/jazz/src/Audio.h =================================================================== --- trunk/jazz/src/Audio.h 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/Audio.h 2010-07-12 01:21:59 UTC (rev 790) @@ -29,29 +29,30 @@ #include <wx/app.h> #include <wx/string.h> -class tEventArray; +class JZSamplesDialog; class JZTrack; -struct tAudioBuffer; class tAudioBufferQueue; class tAudioRecordBuffer; -class tSampleWin; +class tEventArray; class tSample; class tSampleVoice; +class tSampleWin; +struct tAudioBuffer; -// these should be variables and queried from the driver! +// These should be variables and queried from the driver! // -// there is still a bug somewhere: +// There is still a bug somewhere: // FRAGBITS 13 // BUFCOUNT 64 -// midi-speed 114 (trackwin) -// does not work, sounds like it skips a buffer after 18 bars +// MIDI-speed 114 (trackwin) +// Does not work, sounds like it skips a buffer after 18 bars. // // 1MB of buffer data seems to be reasonable. #ifdef __WXMSW__ -// mswin has big buffers, good! +// Microsoft Windows has big buffers. #define FRAGBITS 14 #define FRAGBYTES (1 << FRAGBITS) // # bytes @@ -62,8 +63,8 @@ #else -// linux only has 64K buffers and wastes one fragment. So keep -// fragments small +// Linux only has 64K buffers and wastes one fragment, so keep the fragments +// small. #define FRAGBITS 13 #define FRAGBYTES (1 << FRAGBITS) // # bytes @@ -72,17 +73,14 @@ #define BUFBYTES FRAGBYTES #define BUFCOUNT 128 // # buffers -#endif +#define WAVEHDR char - -// ============================================================= -// AudioBuffers -// ============================================================= - -#ifndef __WXMSW__ -#define WAVEHDR char #endif +//***************************************************************************** +// Description: +// This is the audio buffer structure declaration. +//***************************************************************************** struct tAudioBuffer { // This is a Microsoft Windows for mswin wavehdr @@ -118,7 +116,8 @@ DECLARE_ARRAY(tAudioBufferArray, tAudioBuffer*) - +//***************************************************************************** +//***************************************************************************** class tAudioBufferQueue { public: @@ -177,8 +176,8 @@ int read, written; }; - - +//***************************************************************************** +//***************************************************************************** class tAudioRecordBuffer { friend class tSampleSet; @@ -215,13 +214,10 @@ }; -// ============================================================= -// tSampleSet -// ============================================================= - -class JZSamplesDialog; - //***************************************************************************** +// Description: +// This is the sample set class declaration. This class holds a collection +// of audio samples that are played when a particular MIDI signal is received. //***************************************************************************** class tSampleSet { @@ -229,7 +225,6 @@ friend class tSampleVoice; friend class tSample; - friend class tAudioGloblForm; friend class JZWindowsAudioPlayer; friend class tAudioPlayer; friend class tAlsaAudioPlayer; @@ -256,26 +251,26 @@ void Edit(int key); - int GetSpeed() const + int GetSamplingRate() const { - return speed; + return mSamplingRate; } - void SetSpeed(int x) + void SetSamplingRate(int SamplingRate) { - dirty |= (speed != x); - speed = x; + dirty |= (mSamplingRate != SamplingRate); + mSamplingRate = SamplingRate; } - int GetChannels() const + int GetChannelCount() const { - return channels; + return mChannelCount; } - void SetChannels(int x) + void SetChannelCount(int ChannelCount) { - dirty |= (channels != x); - channels = x; + dirty |= (mChannelCount != ChannelCount); + mChannelCount = ChannelCount; } int BitsPerSample() const @@ -309,16 +304,18 @@ long Ticks2Samples(long ticks) const { - long spl = - (long)(60.0 * ticks * speed * channels / (double)ticks_per_minute); + long spl = (long)( + 60.0 * ticks * mSamplingRate * mChannelCount / + (double)ticks_per_minute); // Align to the first channel. - return spl & -channels; + return spl & -mChannelCount; } double Samples2Ticks(long samples) const { - return (double)samples * ticks_per_minute / 60.0 / speed / channels; + return (double) + samples * ticks_per_minute / 60.0 / mSamplingRate / mChannelCount; } // time in millisec @@ -334,12 +331,12 @@ long Samples2Time(long samples) const { - return (long)(1000.0 * samples / speed / channels); + return (long)(1000.0 * samples / mSamplingRate / mChannelCount); } long Time2Samples(long time) const { - return (long)(0.001 * time * speed * channels); + return (long)(0.001 * time * mSamplingRate * mChannelCount); } virtual const std::string& GetSampleLabel(int Index); @@ -388,7 +385,7 @@ long SampleSize(long num_samples) { - return channels * (bits == 8 ? 1L : 2L) * num_samples; + return mChannelCount * (bits == 8 ? 1L : 2L) * num_samples; } long BufferClock(int i) const @@ -400,15 +397,19 @@ protected: - long speed; // samples / second - int channels; // mono = 1, stereo = 2 + // Sampling rate in samples per second or Hz. + int mSamplingRate; + + // mono = 1, stereo = 2 + int mChannelCount; + int bits; // must be 16! bool softsync; // enable software midi/audio sync tSample* mSamples[eSampleCount]; tSampleWin* mSampleWindows[eSampleCount]; - long ticks_per_minute; // midi speed for audio/midi sync + long ticks_per_minute; // MIDI sampling rate for audio/midi sync. double clocks_per_buffer; long start_clock; // when did play start @@ -424,7 +425,6 @@ // return the start clock for i-th free buffer long buffers_written; // for computing buffers clock - wxDialog* mpGlobalSettingsDialog; JZSamplesDialog* mpSampleDialog; tEventArray* events; Added: trunk/jazz/src/Dialogs/AudioSettingsDialog.cpp =================================================================== --- trunk/jazz/src/Dialogs/AudioSettingsDialog.cpp (rev 0) +++ trunk/jazz/src/Dialogs/AudioSettingsDialog.cpp 2010-07-12 01:21:59 UTC (rev 790) @@ -0,0 +1,89 @@ +#include "AudioSettingsDialog.h" + +#include "../Audio.h" + +#include <wx/button.h> +#include <wx/checkbox.h> +#include <wx/combobox.h> +#include <wx/sizer.h> +#include <wx/stattext.h> + +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZAudioSettingsDialog::JZAudioSettingsDialog( + wxWindow* pParent, + tSampleSet& SampleSet) + : wxDialog(pParent, wxID_ANY, wxString("Audio Settings")), + mSampleSet(SampleSet), + mpEnableAudioCheckBox(0), + mpSamplingRateComboBox(0), + mpStereoCheckBox(0), + mpSoftwareMidiAudioSyncCheckBox(0) +{ + mpEnableAudioCheckBox = new wxCheckBox(this, wxID_ANY, "Enable Audio"); + + wxArrayString SampleRates; + SampleRates.push_back("8000"); + SampleRates.push_back("11025"); + SampleRates.push_back("22050"); + SampleRates.push_back("44100"); + + mpSamplingRateComboBox = new wxComboBox( + this, + wxID_ANY, + "", + wxDefaultPosition, + wxDefaultSize, + SampleRates); + + mpStereoCheckBox = new wxCheckBox(this, wxID_ANY, "Stereo"); + + mpSoftwareMidiAudioSyncCheckBox = new wxCheckBox( + this, + wxID_ANY, + "Software MIDI/Audio Sync"); + + wxButton* pOkButton = new wxButton(this, wxID_OK, "&OK"); + wxButton* pCancelButton = new wxButton(this, wxID_CANCEL, "Cancel"); + wxButton* pHelpButton = new wxButton(this, wxID_HELP, "Help"); + pOkButton->SetDefault(); + + wxBoxSizer* pTopSizer = new wxBoxSizer(wxVERTICAL); + wxFlexGridSizer* pFlexGridSizer; + + pTopSizer->Add(mpEnableAudioCheckBox, 0, wxALIGN_CENTER | wxALL, 3); + + pFlexGridSizer = new wxFlexGridSizer(1, 2, 4, 2); + pFlexGridSizer->Add( + new wxStaticText(this, wxID_ANY, "Sample Rate"), + 0, + wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pFlexGridSizer->Add( + mpSamplingRateComboBox, + 0, + wxALIGN_CENTER_VERTICAL); + pTopSizer->Add(pFlexGridSizer, 0, wxALIGN_CENTER | wxALL, 3); + + pTopSizer->Add(mpStereoCheckBox, 0, wxALIGN_CENTER | wxALL, 3); + + pTopSizer->Add( + mpSoftwareMidiAudioSyncCheckBox, + 0, + wxALIGN_CENTER | wxALL, + 3); + + wxBoxSizer* pButtonSizer = new wxBoxSizer(wxHORIZONTAL); + pButtonSizer->Add(pOkButton, 0, wxALL, 5); + pButtonSizer->Add(pCancelButton, 0, wxALL, 5); + pButtonSizer->Add(pHelpButton, 0, wxALL, 5); + + pTopSizer->Add(pButtonSizer, 0, wxALIGN_CENTER | wxBOTTOM, 6); + + SetAutoLayout(true); + SetSizer(pTopSizer); + + pTopSizer->SetSizeHints(this); + pTopSizer->Fit(this); +} Property changes on: trunk/jazz/src/Dialogs/AudioSettingsDialog.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/jazz/src/Dialogs/AudioSettingsDialog.h =================================================================== --- trunk/jazz/src/Dialogs/AudioSettingsDialog.h (rev 0) +++ trunk/jazz/src/Dialogs/AudioSettingsDialog.h 2010-07-12 01:21:59 UTC (rev 790) @@ -0,0 +1,48 @@ +//***************************************************************************** +// The JAZZ++ Midi Sequencer +// +// Copyright (C) 2010 Peter J. Stieber, all rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//***************************************************************************** + +#ifndef JZ_AUDIOSETTINGSDIALOG_H +#define JZ_AUDIOSETTINGSDIALOG_H + +#include <wx/dialog.h> + +class tSampleSet; +class wxCheckBox; +class wxComboBox; + +//***************************************************************************** +//***************************************************************************** +class JZAudioSettingsDialog : public wxDialog +{ + public: + + JZAudioSettingsDialog(wxWindow* pParent, tSampleSet& SampleSet); + + private: + + tSampleSet& mSampleSet; + + wxCheckBox* mpEnableAudioCheckBox; + wxComboBox* mpSamplingRateComboBox; + wxCheckBox* mpStereoCheckBox; + wxCheckBox* mpSoftwareMidiAudioSyncCheckBox; +}; + +#endif // !defined(JZ_AUDIOSETTINGSDIALOG_H) Property changes on: trunk/jazz/src/Dialogs/AudioSettingsDialog.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/jazz/src/Makefile.am =================================================================== --- trunk/jazz/src/Makefile.am 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/Makefile.am 2010-07-12 01:21:59 UTC (rev 790) @@ -22,6 +22,7 @@ DeprecatedWx/prop.cpp \ DeprecatedWx/propform.cpp \ DeprecatedWx/proplist.cpp \ +Dialogs/AudioSettingsDialog.cpp \ Dialogs/CleanupDialog.cpp \ Dialogs/ControllerDialog.cpp \ Dialogs/DeleteDialog.cpp \ @@ -119,6 +120,7 @@ DeprecatedWx/prop.cpp \ DeprecatedWx/propform.cpp \ DeprecatedWx/proplist.cpp \ +Dialogs/AudioSettingsDialog.cpp \ Dialogs/CleanupDialog.cpp \ Dialogs/ControllerDialog.cpp \ Dialogs/DeleteDialog.cpp \ @@ -221,6 +223,7 @@ DeprecatedWx/propform.h \ DeprecatedWx/proplist.h \ DeprecatedStringUtils.h \ +Dialogs/AudioSettingsDialog.h \ Dialogs/CleanupDialog.h \ Dialogs/ControllerDialog.h \ Dialogs/DeleteDialog.h \ Modified: trunk/jazz/src/Player.h =================================================================== --- trunk/jazz/src/Player.h 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/Player.h 2010-07-12 01:21:59 UTC (rev 790) @@ -243,13 +243,16 @@ virtual void StartAudio() { } - virtual int GetAudioEnabled() const + + virtual bool GetAudioEnabled() const { - return 0; + return false; } - virtual void SetAudioEnabled(int) + + virtual void SetAudioEnabled(bool AudioEnabled) { } + virtual void ListenAudio(int key, int start_stop_mode = 1) { } Modified: trunk/jazz/src/Sample.cpp =================================================================== --- trunk/jazz/src/Sample.cpp 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/Sample.cpp 2010-07-12 01:21:59 UTC (rev 790) @@ -309,7 +309,7 @@ } // convert mono -> stereo - if (channels == 1 && set.channels == 2) + if (channels == 1 && set.GetChannelCount() == 2) { short *old = data; length = length * 2; @@ -325,7 +325,7 @@ channels = 2; } // convert stereo -> mono - else if (channels == 2 && set.channels == 1) + else if (channels == 2 && set.GetChannelCount() == 1) { short *old = data; length = length / 2; @@ -345,9 +345,9 @@ // convert sampling speed if (pitch != 0) speed = (int)(speed * pow(FSEMI, pitch)); - if (speed != set.speed) + if (speed != set.GetSamplingRate()) { - float f = (float)speed / (float)set.speed; + float f = (float)speed / (float)set.GetSamplingRate(); Transpose(f); } @@ -356,7 +356,7 @@ { int ch1 = volume; int ch2 = volume; - int ppan = (set.channels == 2) ? pan : 0; + int ppan = (set.GetChannelCount() == 2) ? pan : 0; if (ppan > 0) ch1 = (int)volume * (63L - ppan) / 64L; else if (ppan < 0) @@ -426,7 +426,7 @@ offs = 0; else if (offs > length) offs = length; - return offs & -(int)set.channels; + return offs & - set.GetChannelCount(); } @@ -528,7 +528,7 @@ void tSample::Flip(int ch) { int i = ch; - int step = set.GetChannels(); + int step = set.GetChannelCount(); while (i < length) { data[i] = -data[i]; @@ -553,13 +553,13 @@ int tSample::GetSamplingRate() const { - return set.GetSpeed(); + return set.GetSamplingRate(); } -int tSample::GetChannels() const +int tSample::GetChannelCount() const { - return set.GetChannels(); + return set.GetChannelCount(); } @@ -603,7 +603,7 @@ void tSample::Transpose(float f) { - int channels = set.GetChannels(); + int channels = set.GetChannelCount(); int new_length = ((int)((double)length / (double)f) & (-channels)); short *new_data = new short [new_length]; @@ -629,13 +629,23 @@ int tSample::Seconds2Samples(float time) { - JZMapper Map(0.0, 1.0, 0.0, (double)set.speed * set.channels); + JZMapper Map( + 0.0, + 1.0, + 0.0, + (double)set.GetSamplingRate() * set.GetChannelCount()); + return static_cast<int>(Map.XToY(time)); } float tSample::Samples2Seconds(int samples) { - JZMapper Map(0.0, (double)set.speed * set.channels, 0.0, 1.0); + JZMapper Map( + 0.0, + (double)set.GetSamplingRate() * set.GetChannelCount(), + 0.0, + 1.0); + return (float)Map.XToY(samples); } @@ -683,19 +693,19 @@ int tSample::SaveWave() { WaveHeader wh; - wh.main_chunk = RIFF; - wh.chunk_type = WAVE; - wh.sub_chunk = FMT; - wh.data_chunk = DATA; - wh.format = PCM_CODE; - wh.modus = set.channels; - wh.sc_len = 16; - wh.sample_fq = set.speed; - wh.bit_p_spl = set.bits; - wh.byte_p_spl = set.channels * (set.bits > 8 ? 2 : 1); - wh.byte_p_sec = wh.byte_p_spl * wh.sample_fq; - wh.data_length = length * sizeof(short); - wh.length = wh.data_length + sizeof(WaveHeader); + wh.main_chunk = RIFF; + wh.chunk_type = WAVE; + wh.sub_chunk = FMT; + wh.data_chunk = DATA; + wh.format = PCM_CODE; + wh.modus = set.GetChannelCount(); + wh.sc_len = 16; + wh.sample_fq = set.GetSamplingRate(); + wh.bit_p_spl = set.bits; + wh.byte_p_spl = set.GetChannelCount() * (set.bits > 8 ? 2 : 1); + wh.byte_p_sec = wh.byte_p_spl * wh.sample_fq; + wh.data_length = length * sizeof(short); + wh.length = wh.data_length + sizeof(WaveHeader); #ifdef __WXMSW__ unlink(mFileName.c_str()); // buggy, sigh! @@ -719,8 +729,8 @@ data = new float [length]; for (int i = 0; i < length; i++) data[i] = (float)spl.data[i]; - channels = spl->GetChannels(); - sampling_rate = spl->GetSpeed(); + channels = spl->GetChannelCount(); + sampling_rate = spl->GetSamplingRate(); } tFloatSample::tFloatSample(tSample &spl, int fr, int to) @@ -730,8 +740,8 @@ data = new float [length]; for (int i = 0; i < length; i++) data[i] = (float)spl.data[i + fr]; - channels = spl->GetChannels(); - sampling_rate = spl->GetSpeed(); + channels = spl->GetChannelCount(); + sampling_rate = spl->GetSamplingRate(); } tFloatSample::tFloatSample(int ch, int sr) Modified: trunk/jazz/src/Sample.h =================================================================== --- trunk/jazz/src/Sample.h 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/Sample.h 2010-07-12 01:21:59 UTC (rev 790) @@ -153,7 +153,7 @@ void AssureLength(int new_length); - int GetChannels() const + int GetChannelCount() const { return channels; } @@ -195,9 +195,9 @@ * data[n+1] == 2nd value for left channel * ... * all length values mean number of shorts and - * should be multiples of of set.GetChannels(). + * should be multiples of of set.GetChannelCount(). * Offsets should start on channel boundaries, - * that is offs % set.GetChannels() == 0. + * that is offs % set.GetChannelCount() == 0. */ class tSample @@ -315,7 +315,8 @@ return &set; } - int GetChannels() const; + int GetChannelCount() const; + int GetSamplingRate() const; /** Modified: trunk/jazz/src/SampleCommand.cpp =================================================================== --- trunk/jazz/src/SampleCommand.cpp 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/SampleCommand.cpp 2010-07-12 01:21:59 UTC (rev 790) @@ -3,7 +3,7 @@ // // Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all rights reserved. // Modifications Copyright (C) 2004 Patrick Earl -// Modifications Copyright (C) 2008 Peter J. Stieber +// Modifications Copyright (C) 2008-2010 Peter J. Stieber // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -100,7 +100,7 @@ if (n <= 0) return; // no data - long channels = spl.GetChannels(); + long channels = spl.GetChannelCount(); float N = spl.length / channels - 2; short *data = spl.data; @@ -238,7 +238,7 @@ void tWahWah::Execute(long fr, long to) { tFloatSample *out = new tFloatSample(spl); - for (int c = 0; c < out->GetChannels(); c++) + for (int c = 0; c < out->GetChannelCount(); c++) Wah(c, *out); out->Rescale(); spl.Set(*out); @@ -251,7 +251,7 @@ { long N = spl.GetLength(); float SR = spl.GetSamplingRate(); - long channels = spl.GetChannels(); + long channels = spl.GetChannelCount(); JZMapper XMap(0, N, 0, arr.Size()); JZMapper fmap(0, 100, lo_freq, hi_freq); @@ -297,7 +297,7 @@ { JZMapper wmap(0, 100, 0.05, 0.3); tFloatSample inp(spl); - tFloatSample out(inp.GetChannels(), inp.GetSamplingRate()); + tFloatSample out(inp.GetChannelCount(), inp.GetSamplingRate()); float p[8]; p[0] = 0; p[1] = 0; @@ -308,7 +308,7 @@ p[6] = 0; p[7] = 0; rotate(p, 8, inp, out); - if (inp.GetChannels() == 2) + if (inp.GetChannelCount() == 2) { p[6] = 1; p[7] = 1; @@ -337,7 +337,7 @@ { JZMapper wmap(0, 100, 0.05, 0.3); tFloatSample inp(spl); - tFloatSample out(inp.GetChannels(), inp.GetSamplingRate()); + tFloatSample out(inp.GetChannelCount(), inp.GetSamplingRate()); float p[8]; p[0] = 0; p[1] = 0; @@ -348,7 +348,7 @@ p[6] = 0; p[7] = 0; rotate(p, 8, inp, out); - if (inp.GetChannels() == 2) + if (inp.GetChannelCount() == 2) { p[6] = 1; p[7] = 1; @@ -403,7 +403,7 @@ reinit = (int)(p[5] * SR); off = reinit/2; k = off; - chans = sout.GetChannels(); + chans = sout.GetChannelCount(); inchan = (int)p[6]; j = 0; for (i = 0; i < nsamps; i++) Modified: trunk/jazz/src/SampleDialog.cpp =================================================================== --- trunk/jazz/src/SampleDialog.cpp 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/SampleDialog.cpp 2010-07-12 01:21:59 UTC (rev 790) @@ -3,7 +3,7 @@ // // Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all rights reserved. // Modifications Copyright (C) 2004 Patrick Earl -// Modifications Copyright (C) 2008 Peter J. Stieber +// Modifications Copyright (C) 2008-2010 Peter J. Stieber // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -111,7 +111,7 @@ spl(w.GetSample()) { int i; - channels = spl.GetChannels(); + channels = spl.GetChannelCount(); for (i = 0; i < array.Size(); ++i) { array[i] = 0; @@ -172,7 +172,7 @@ float oldpeak = fs.Peak(); int i = 0; - int channels = fs.GetChannels(); + int channels = fs.GetChannelCount(); int n = to - fr; float *data = fs.GetData(); @@ -991,7 +991,7 @@ float peak = fs.Peak(); if (rand) { - if (fs.GetChannels() == 2) + if (fs.GetChannelCount() == 2) fs.RndEchoStereo(num_echos, dmap(delay), (float)amap(ampl)); else fs.RndEcho(num_echos, dmap(delay), (float)amap(ampl)); @@ -1073,7 +1073,7 @@ { JZMapper wmap(0, 100, 0.05, 0.3); tFloatSample inp(spl); - tFloatSample out(inp.GetChannels(), inp.GetSamplingRate()); + tFloatSample out(inp.GetChannelCount(), inp.GetSamplingRate()); //float peak = inp.Peak(); tShifterCmd shifter(inp, out); @@ -1088,7 +1088,7 @@ p[6] = 0; p[7] = 0; shifter.rotate(p, 8); - if (inp.GetChannels() == 2) + if (inp.GetChannelCount() == 2) { p[6] = 1; p[7] = 1; Modified: trunk/jazz/src/SampleWindow.cpp =================================================================== --- trunk/jazz/src/SampleWindow.cpp 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/SampleWindow.cpp 2010-07-12 01:21:59 UTC (rev 790) @@ -317,7 +317,7 @@ { int cw, ch; GetClientSize(&cw, &ch); -// snapsel.SetYSnap(0, ch, ch / spl.GetChannels()); +// snapsel.SetYSnap(0, ch, ch / spl.GetChannelCount()); snapsel.SetYSnap(0, ch, ch); AdjustScrollbars(); @@ -467,7 +467,7 @@ int cw, ch; GetClientSize(&cw, &ch); - int n = spl.GetChannels(); + int n = spl.GetChannelCount(); for (int i = 0; i < n; ++i) { int x = 0; @@ -579,7 +579,7 @@ { const short* data = spl.GetData(); int length = spl.GetLength(); - int step = spl.GetChannels(); + int step = spl.GetChannelCount(); // compute display range from position scrollbar int xfr = paint_offset + channel; @@ -887,15 +887,15 @@ int yy = ToolBarSize.GetHeight(); int ww = cw; int hh = ch - ToolBarSize.GetHeight() - zh - ph; - int nn = spl.GetChannels() + num_params; + int nn = spl.GetChannelCount() + num_params; - int hi = hh * spl.GetChannels() / nn; + int hi = hh * spl.GetChannelCount() / nn; cnvs->SetSize(xx, yy, ww, hi); hi = hh / nn; for (int i = 0; i < num_params; i++) { - int yi = yy + (i + spl.GetChannels()) * hh / nn; + int yi = yy + (i + spl.GetChannelCount()) * hh / nn; params[i]->SetSize(xx, yi, ww, hi); } } Modified: trunk/jazz/src/Signal2.cpp =================================================================== --- trunk/jazz/src/Signal2.cpp 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/Signal2.cpp 2010-07-12 01:21:59 UTC (rev 790) @@ -3,7 +3,7 @@ // // Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all rights reserved. // Modifications Copyright (C) 2004 Patrick Earl -// Modifications Copyright (C) 2008 Peter J. Stieber +// Modifications Copyright (C) 2008-2010 Peter J. Stieber // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -77,7 +77,7 @@ float room_val) // echo delay { long sr = spl.GetSamplingRate(); - long ch = spl.GetChannels(); + long ch = spl.GetChannelCount(); tSigSynth synth(sr, ch); tShortIter isig(synth, spl); @@ -115,7 +115,7 @@ float volume) // 0..1 { long sr = spl.GetSamplingRate(); - long ch = spl.GetChannels(); + long ch = spl.GetChannelCount(); tSigSynth synth(sr, ch); tShortIter isig(synth, spl); @@ -200,7 +200,7 @@ ) { long sr = spl.GetSamplingRate(); - long ch = spl.GetChannels(); + long ch = spl.GetChannelCount(); tSigSynth synth(sr, ch); FreqTab ft; double freq = ft.freq(midi_key); Modified: trunk/jazz/src/Signal2.h =================================================================== --- trunk/jazz/src/Signal2.h 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/Signal2.h 2010-07-12 01:21:59 UTC (rev 790) @@ -3,7 +3,7 @@ // // Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all rights reserved. // Modifications Copyright (C) 2004 Patrick Earl -// Modifications Copyright (C) 2008 Peter J. Stieber +// Modifications Copyright (C) 2008-2010 Peter J. Stieber // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -314,7 +314,7 @@ generators.push_back(&gen); } - int GetChannels() const + int GetChannelCount() const { return channels; } @@ -349,7 +349,7 @@ tSigInput(tSigSynth &parent) : synth(parent) { synth.AddGenerator(*this); - channels = synth.GetChannels(); + channels = synth.GetChannelCount(); sampling_rate = synth.GetSamplingRate(); current = -1; } @@ -506,8 +506,8 @@ { Resize(this->GetLength() * 2); } - long idata = this->GetCurrent() * this->GetChannels(); - for (int i = 0; i < this->GetChannels(); i++) + long idata = this->GetCurrent() * this->GetChannelCount(); + for (int i = 0; i < this->GetChannelCount(); i++) { this->data[idata++] = (T)v[i]; } @@ -599,7 +599,7 @@ public: tSigWaveOscil(tSigSynth &synth, int N, double f, double ffact = FSEMI) : tSignalModifier(synth), - array(N, synth.GetChannels()), + array(N, synth.GetChannelCount()), freq(f), SR(synth.GetSamplingRate()), frqfact(ffact) @@ -659,7 +659,7 @@ public: tSigWaveCtrl(tSigSynth &synth, int N, double durat) : tSigInput(synth), - array(N, synth.GetChannels()), + array(N, synth.GetChannelCount()), xmap(0, synth.GetSamplingRate() * durat, 0, N) { } @@ -806,7 +806,7 @@ tSigDelay(tSigSynth &synth, float time) : tSignalModifier(synth), size((long)(time * sampling_rate) + 2), - array(size, synth.GetChannels()) + array(size, synth.GetChannelCount()) { map.Initialize(-1, 1, 0, -size+1); } @@ -1045,7 +1045,7 @@ tSigComb(tSigSynth &synth, float loop_time, float reverb_time) : tSignalModifier(synth), size((long)(loop_time * synth.GetSamplingRate())), - array(size+2, synth.GetChannels()) + array(size+2, synth.GetChannelCount()) { coeff = exp((double)(log001 * loop_time / reverb_time)); } Modified: trunk/jazz/src/mswin/WindowsAudioInterface.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsAudioInterface.cpp 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/mswin/WindowsAudioInterface.cpp 2010-07-12 01:21:59 UTC (rev 790) @@ -3,7 +3,7 @@ // // Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all rights reserved. // Modifications Copyright (C) 2004 Patrick Earl -// Modifications Copyright (C) 2008 Peter J. Stieber +// Modifications Copyright (C) 2008-2010 Peter J. Stieber // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -63,7 +63,7 @@ // Indicate that we are not recording! mpPlayer->mpRecordingInfo = 0; - mChannels = mpPlayer->mSamples.GetChannels(); + mChannels = mpPlayer->mSamples.GetChannelCount(); mCount = mpPlayer->mSamples.PrepareListen(key); @@ -90,7 +90,7 @@ // Indicate that we are not recording! mpPlayer->mpRecordingInfo = 0; - mChannels = mpPlayer->mSamples.GetChannels(); + mChannels = mpPlayer->mSamples.GetChannelCount(); mCount = mpPlayer->mSamples.PrepareListen(&spl, fr_smpl, to_smpl); @@ -150,17 +150,20 @@ mErrorCode(NoError), mCanDuplex(false), mCanSynchronize(true), + mInstalled(false), + mAudioEnabled(false), + blocks_played(0), + play_buffers_needed(0), + start_clock(0), + start_time(0), mpListener(0) { mpState->audio_player = this; InitializeCriticalSection(&mutex); - long dummy = 0; mpAudioBuffer = new tEventArray(); - mInstalled = false; - dummy = gpConfig->GetValue(C_EnableAudio); - audio_enabled = dummy; + mAudioEnabled = (gpConfig->GetValue(C_EnableAudio) != 0); hout_open = 0; hinp_open = 0; @@ -193,7 +196,7 @@ } } recbuffers.Clear(); - audio_enabled = (audio_enabled && mInstalled); + mAudioEnabled = (mAudioEnabled && mInstalled); } //----------------------------------------------------------------------------- @@ -264,7 +267,7 @@ mErrorCode = NoError; // everything ok for now. - if (!audio_enabled) + if (!mAudioEnabled) { return 0; } @@ -275,9 +278,9 @@ WAVEFORMATEX fmt; memset(&fmt, 0, sizeof(fmt)); fmt.wFormatTag = WAVE_FORMAT_PCM; - fmt.nChannels = mSamples.GetChannels(); - fmt.nSamplesPerSec = mSamples.GetSpeed(); - fmt.nBlockAlign = mSamples.GetChannels() * sizeof(short); + fmt.nChannels = mSamples.GetChannelCount(); + fmt.nSamplesPerSec = mSamples.GetSamplingRate(); + fmt.nBlockAlign = mSamples.GetChannelCount() * sizeof(short); fmt.nAvgBytesPerSec = fmt.nBlockAlign * fmt.nSamplesPerSec; fmt.wBitsPerSample = 16; fmt.cbSize = 0; @@ -490,7 +493,7 @@ //----------------------------------------------------------------------------- void JZWindowsAudioPlayer::WriteBuffers() { - if (audio_enabled && hout_open) + if (mAudioEnabled && hout_open) { tAudioBuffer* pAudioBuffer; while ((pAudioBuffer = mSamples.full_buffers.Get()) != 0) @@ -517,7 +520,7 @@ //----------------------------------------------------------------------------- void JZWindowsAudioPlayer::Notify() { - if (audio_enabled) + if (mAudioEnabled) { EnterCriticalSection(&mutex); @@ -539,8 +542,9 @@ if (res == MMSYSERR_NOERROR && mmtime.wType == TIME_SAMPLES) { long time_now = (long)timeGetTime(); - long audio_now = - (long)((double)start_time + 1000.0 * mmtime.u.sample / mSamples.speed); + long audio_now = (long)( + (double)start_time + 1000.0 * mmtime.u.sample / + mSamples.GetSamplingRate()); // low pass filter for time-correction (not really necessary) const long low = 50; @@ -588,9 +592,11 @@ if (res == MMSYSERR_NOERROR && mmtime.wType == TIME_SAMPLES) { long time_now = (long)timeGetTime(); - long audio_now = - (long)((double)mpState->start_time + 1000.0 * mmtime.u.sample / mSamples.speed); - // low pass filter for time-correction (not really necessary) + long audio_now = (long)( + (double)mpState->start_time + 1000.0 * mmtime.u.sample / + mSamples.GetSamplingRate()); + + // Low pass filter for time-correction (not really necessary). const long low = 50; mpState->time_correction = (low * mpState->time_correction + (100 - low) * (audio_now - time_now) ) / 100L; } @@ -598,7 +604,7 @@ } LeaveCriticalSection(&mutex); - } // if (audio_enabled) + } // if (mAudioEnabled) JZWindowsIntPlayer::Notify(); } @@ -610,7 +616,7 @@ mSamples.StartPlay(Clock); JZWindowsIntPlayer::StartPlay(Clock, LoopClock, Continue); - if (!audio_enabled) + if (!mAudioEnabled) { return; } @@ -655,7 +661,7 @@ //----------------------------------------------------------------------------- void JZWindowsAudioPlayer::ListenAudio(int key, int start_stop_mode) { - if (!audio_enabled) + if (!mAudioEnabled) { return; } @@ -684,9 +690,12 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZWindowsAudioPlayer::ListenAudio(tSample &spl, long fr_smpl, long to_smpl) +void JZWindowsAudioPlayer::ListenAudio( + tSample &spl, + long fr_smpl, + long to_smpl) { - if (!audio_enabled) + if (!mAudioEnabled) { return; } Modified: trunk/jazz/src/mswin/WindowsAudioInterface.h =================================================================== --- trunk/jazz/src/mswin/WindowsAudioInterface.h 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/src/mswin/WindowsAudioInterface.h 2010-07-12 01:21:59 UTC (rev 790) @@ -3,7 +3,7 @@ // // Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all rights reserved. // Modifications Copyright (C) 2004 Patrick Earl -// Modifications Copyright (C) 2008 Peter J. Stieber +// Modifications Copyright (C) 2008-2010 Peter J. Stieber // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -71,14 +71,14 @@ return mInstalled && JZWindowsIntPlayer::IsInstalled(); } - virtual int GetAudioEnabled() const + virtual bool GetAudioEnabled() const { - return audio_enabled; + return mAudioEnabled; } - virtual void SetAudioEnabled(int x) + virtual void SetAudioEnabled(bool AudioEnabled) { - audio_enabled = x; + mAudioEnabled = AudioEnabled; } virtual void ListenAudio(int key, int start_stop_mode = 1); @@ -123,6 +123,11 @@ void AudioCallback(UINT msg); + int OpenDsp(); // 0 = ok + int CloseDsp(); // 0 = ok + + private: + TEErrorCode mErrorCode; // Indicates if full duplex record/play is possible. @@ -131,11 +136,11 @@ // Indicates if the exact output play position can be determined. bool mCanSynchronize; - int OpenDsp(); // 0 = ok - int CloseDsp(); // 0 = ok + bool mInstalled; - bool mInstalled; - int audio_enabled; // 0 means midi only + // A value of false means MIDI only. + bool mAudioEnabled; + long blocks_played; // # of blocks written to device int play_buffers_needed; // driver requests more output buffers Modified: trunk/jazz/vc9/JazzPlusPlus-VC9.vcproj =================================================================== --- trunk/jazz/vc9/JazzPlusPlus-VC9.vcproj 2010-07-11 21:45:22 UTC (rev 789) +++ trunk/jazz/vc9/JazzPlusPlus-VC9.vcproj 2010-07-12 01:21:59 UTC (rev 790) @@ -1129,6 +1129,14 @@ Name="Dialog Source Files" > <File + RelativePath="..\src\Dialogs\AudioSettingsDialog.cpp" + > + </File> + <File + RelativePath="..\src\Dialogs\AudioSettingsDialog.h" + > + </File> + <File RelativePath="..\src\Dialogs\CleanupDialog.cpp" > </File> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |