|
From: <pst...@us...> - 2008-04-05 20:12:13
|
Revision: 398
http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=398&view=rev
Author: pstieber
Date: 2008-04-05 13:12:11 -0700 (Sat, 05 Apr 2008)
Log Message:
-----------
1. Removed the include of WxWidgets from some header files.
2. Made cosmetic changes in Audio.h and reduced the number of casts by reordering
operations.
Modified Paths:
--------------
trunk/jazz/src/Audio.h
trunk/jazz/src/ResourceDialog.cpp
trunk/jazz/src/ResourceDialog.h
trunk/jazz/src/Sample.cpp
Modified: trunk/jazz/src/Audio.h
===================================================================
--- trunk/jazz/src/Audio.h 2008-04-05 05:23:55 UTC (rev 397)
+++ trunk/jazz/src/Audio.h 2008-04-05 20:12:11 UTC (rev 398)
@@ -23,10 +23,6 @@
#ifndef JZ_AUDIO_H
#define JZ_AUDIO_H
-#include "WxWidgets.h"
-
-//#include "config.h"
-
#include "DynamicArray.h"
#include "Project.h"
@@ -84,75 +80,95 @@
#define WAVEHDR void
#endif
-struct tAudioBuffer {
+struct tAudioBuffer
+{
+ // This is a Microsoft Windows for mswin wavehdr
+ WAVEHDR* hdr;
+ short* data;
- WAVEHDR *hdr; // for mswin wavehdr
- short *data;
-
- tAudioBuffer(int dummy) {
+ tAudioBuffer(int dummy)
+ {
hdr = 0;
data = new short [BUFSHORTS];
// in case recording stops inside a buffer
memset(data, 0, BUFBYTES);
}
- ~tAudioBuffer() {
+ ~tAudioBuffer()
+ {
delete [] data;
}
- void Clear() {
+ void Clear()
+ {
memset(data, 0, BUFBYTES);
}
- short *Data() {
+ short* Data()
+ {
return data;
}
-
-
};
DECLARE_ARRAY(tAudioBufferArray, tAudioBuffer*)
-class tAudioBufferQueue {
+class tAudioBufferQueue
+{
public:
- tAudioBufferQueue() {
+
+ tAudioBufferQueue()
+ {
Clear();
}
- ~tAudioBufferQueue() {
+ ~tAudioBufferQueue()
+ {
}
- void Clear() {
+ void Clear()
+ {
written = read = 0;
for (int i = 0; i < BUFCOUNT; i++)
+ {
array[i] = 0;
+ }
}
- int Count() const {
+ int Count() const
+ {
return written - read;
}
- int Empty() const {
+ int Empty() const
+ {
return written == read;
}
- void Put(tAudioBuffer *buf) {
+ void Put(tAudioBuffer *buf)
+ {
array[written++ % BUFCOUNT] = buf;
}
- tAudioBuffer *Get() {
+ tAudioBuffer* Get()
+ {
if (written == read)
+ {
return 0;
+ }
return(array[read++ % BUFCOUNT]);
}
- void UnGet(tAudioBuffer *buf) {
+
+ void UnGet(tAudioBuffer* buf)
+ {
array[ --read % BUFCOUNT ] = buf;
}
private:
- tAudioBuffer *array[BUFCOUNT];
+
+ tAudioBuffer* array[BUFCOUNT];
+
int read, written;
};
@@ -162,24 +178,32 @@
{
friend class tSampleSet;
friend class tWinAudioPlayer;
+
public:
- tAudioRecordBuffer() {
+
+ tAudioRecordBuffer()
+ {
num_buffers = 0;
}
- ~tAudioRecordBuffer() {
+
+ ~tAudioRecordBuffer()
+ {
Clear();
}
void Clear();
tAudioBuffer * RequestBuffer();
- void UndoRequest() {
+ void UndoRequest()
+ {
num_buffers--;
}
- void ResetBufferSize(int size) {
+ void ResetBufferSize(int size)
+ {
bufbytes = size;
}
private:
+
tAudioBufferArray buffers;
int num_buffers;
int bufbytes;
@@ -207,7 +231,9 @@
public:
tSampleSet(long ticks_per_minute);
+
virtual ~tSampleSet();
+
int Load(const wxString& FileName);
// load jazz.spl
@@ -272,8 +298,10 @@
long Ticks2Samples(long ticks) const
{
- long spl = (long)((double)ticks * 60.0 * speed * channels / (double)ticks_per_minute);
- // align to first channel
+ long spl =
+ (long)(60.0 * ticks * speed * channels / (double)ticks_per_minute);
+
+ // Align to the first channel.
return spl & -channels;
}
@@ -285,7 +313,7 @@
// time in millisec
long Ticks2Time(long ticks) const
{
- return (long)((double)ticks * 60000.0 / ticks_per_minute);
+ return (long)(60000.0 * ticks / ticks_per_minute);
}
long Time2Ticks(long time) const
@@ -295,7 +323,7 @@
long Samples2Time(long samples) const
{
- return (long)(1000.0 * (double)samples / speed / channels);
+ return (long)(1000.0 * samples / speed / channels);
}
long Time2Samples(long time) const
@@ -304,17 +332,28 @@
}
virtual const char *GetSampleName(int i);
+
int OnMenuCommand(int id);
+
void StartPlay(long clock);
+
void StopPlay();
// returns number of buffers prepared. Output starts at offs.
int PrepareListen(int key, long fr_smpl = -1, long to_smpl = -1);
+
int PrepareListen(tSample *spl, long fr_smpl = -1, long to_smpl = -1);
+
int ContinueListen(); // return number of buffers
void SaveRecordingDlg(long frc, long toc, tAudioRecordBuffer &buf);
- void SaveWave(const char *fname, long frc, long toc, tAudioRecordBuffer &buf);
+
+ void SaveWave(
+ const char *fname,
+ long frc,
+ long toc,
+ tAudioRecordBuffer &buf);
+
void AddNote(const char *fname, long frc, long toc);
void RefreshDialogs();
@@ -380,7 +419,7 @@
int dirty; // needs reloading
// to communicate between PrepareListen and ContinueListen
- tSample *listen_sample;
+ tSample* listen_sample;
};
#endif // !defined(JZ_AUDIO_H)
Modified: trunk/jazz/src/ResourceDialog.cpp
===================================================================
--- trunk/jazz/src/ResourceDialog.cpp 2008-04-05 05:23:55 UTC (rev 397)
+++ trunk/jazz/src/ResourceDialog.cpp 2008-04-05 20:12:11 UTC (rev 398)
@@ -16,6 +16,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "WxWidgets.h"
+
#include <wx/fs_zip.h>
#include <wx/xrc/xmlres.h>
Modified: trunk/jazz/src/ResourceDialog.h
===================================================================
--- trunk/jazz/src/ResourceDialog.h 2008-04-05 05:23:55 UTC (rev 397)
+++ trunk/jazz/src/ResourceDialog.h 2008-04-05 20:12:11 UTC (rev 398)
@@ -23,8 +23,6 @@
#ifndef JZ_RESOURCEDIALOG_H
#define JZ_RESOURCEDIALOG_H
-#include "WxWidgets.h"
-
#include <list>
/// Used by jppResourceDialog to store "Attach" entries.
@@ -35,7 +33,8 @@
fields should all be set to zero, except the one that needs to be filled.
The constructor will set all the fields to zero. */
-class jppResourceElement {
+class jppResourceElement
+{
public:
/// ID of the widget in the XRC resource.
wxString resource;
Modified: trunk/jazz/src/Sample.cpp
===================================================================
--- trunk/jazz/src/Sample.cpp 2008-04-05 05:23:55 UTC (rev 397)
+++ trunk/jazz/src/Sample.cpp 2008-04-05 20:12:11 UTC (rev 398)
@@ -20,7 +20,8 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//*****************************************************************************
-//#include "config.h"
+#include "WxWidgets.h"
+
#include "Sample.h"
#include "Audio.h"
#include "Random.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|