Skip to content

Commit 8bc1def

Browse files
committed
Cleanup
1 parent ca6d453 commit 8bc1def

File tree

9 files changed

+43
-40
lines changed

9 files changed

+43
-40
lines changed

src/ArdConfig.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
by Phil Schatzmann
88
*/
99

10+
#ifndef USE_FILES
11+
#define __RAW_ARRAYS__ // raw files as compilable c arrays
12+
#endif
13+
1014
#if defined(ESP32)
1115
// #define __MIDI__ // support Midi
1216
#define __I2S__
13-
#define __RAW_ARRAYS__ // raw files as compilable c arrays
1417
#define __STREAMS__ // output to Ardiono Streams
1518
#define __RTOS__ // supports Free RTOS
1619
#define __LWIP__ // use lwip socket implementation
@@ -22,7 +25,6 @@
2225
#elif defined(ESP8266)
2326
// #define __MIDI__ // support Midi
2427
// #define __I2S__
25-
#define __RAW_ARRAYS__
2628
#define __STREAMS__
2729
#define __NO_EXCEPTIONS__ // comment out exceptions
2830
#define __NO_FSTREAM__ // No Messanger, MidiFileIn and Skini and FileRead
@@ -35,7 +37,6 @@
3537
// #define __MIDI__ // support Midi
3638
#define __ARDUINO__ // exclude standard c++ h files
3739
#define __STREAMS__ // output to Ardiono Streams
38-
#define __RAW_ARRAYS__ // raw files as compilable c arrays
3940
#define __NO_EXCEPTIONS__ // comment out exceptions
4041
#define __NO_FSTREAM__ // No Messanger, MidiFileIn and Skini and FileRead
4142
#define __NO_RT__ // no STK RT functions
@@ -44,14 +45,14 @@
4445
#define STK_ERROR_MSG_LEN 200
4546
extern char stk_error_msg[STK_ERROR_MSG_LEN];
4647
#define ESP_LOGD(APP,...) { snprintf(stk_error_msg, STK_ERROR_MSG_LEN, __VA_ARGS__); Serial.println(stk_error_msg); }
48+
4749
#elif defined(IS_DESKTOP)
4850
// #define __MIDI__ // support Midi
4951
#define __ARDUINO__ // exclude standard c++ h files
5052
#define __STREAMS__ // output to Ardiono Streams
51-
#define __RAW_ARRAYS__ // raw files as compilable c arrays
52-
#define __NO_EXCEPTIONS__ // comment out exceptions
53-
#define __NO_FSTREAM__ // No Messanger, MidiFileIn and Skini and FileRead
54-
#define __NO_RT__ // no STK RT functions
53+
// #define __NO_EXCEPTIONS__ // comment out exceptions
54+
// #define __NO_FSTREAM__ // No Messanger, MidiFileIn and Skini and FileRead
55+
// #define __NO_RT__ // no STK RT functions
5556

5657
// Logging support
5758
#define STK_ERROR_MSG_LEN 200

src/BeeThree.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ BeeThree :: BeeThree( void )
4747
{
4848
#ifdef __RAW_ARRAYS__
4949
for ( unsigned int i=0; i<3; i++ ){
50-
waves_[i] = new MemoryLoop( (Stk::rawwavePath() + "sinewave.raw").c_str(), sinewave_raw,sinewave_raw_len );
50+
waves_[i] = new MemoryLoop(( Stk::rawwavePath() + "sinewave.raw"), sinewave_raw,sinewave_raw_len );
5151
}
52-
waves_[3] = new MemoryLoop( (Stk::rawwavePath() + "fwavblnk.raw").c_str(), fwavblnk_raw,fwavblnk_raw_len );
52+
waves_[3] = new MemoryLoop(( Stk::rawwavePath() + "fwavblnk.raw"), fwavblnk_raw,fwavblnk_raw_len );
5353
#else
5454
for ( unsigned int i=0; i<3; i++ ){
55-
waves_[i] = new FileLoop( (Stk::rawwavePath() + "sinewave.raw").c_str(), true );
55+
waves_[i] = new FileLoop( (Stk::rawwavePath() + "sinewave.raw"), true );
5656
}
57-
waves_[3] = new FileLoop( (Stk::rawwavePath() + "fwavblnk.raw").c_str(), true );
57+
waves_[3] = new FileLoop( (Stk::rawwavePath() + "fwavblnk.raw"), true );
5858
#endif
5959

6060
this->setRatio( 0, 0.999 );

src/FileLoop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void FileLoop :: openFile( std::string fileName, bool raw, bool doNormalize, boo
8888
// Set default rate based on file sampling rate.
8989
this->setRate( data_.dataRate() / Stk::sampleRate() );
9090

91-
if ( doNormalize & !chunking_ ) this->normalize();
91+
if ( doNormalize && !chunking_ ) this->normalize();
9292

9393
this->reset();
9494
}

src/FileRead.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
/***************************************************/
3333

3434
#include "FileRead.h"
35-
#ifndef __ARDUINO__
35+
#if !defined(__ARDUINO__) || defined(IS_DESKTOP)
3636
#include <sys/stat.h>
3737
#include <sys/types.h>
3838
#endif

src/MemoryLoop.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,29 @@
1717

1818
namespace stk {
1919

20-
MemoryLoop :: MemoryLoop(unsigned long chunkSize){
21-
chunkSize_ = chunkSize;
20+
MemoryLoop :: MemoryLoop(unsigned long chunkSize)
21+
: FileLoop(chunkSize*10, chunkSize) {
2222
Stk::addSampleRateAlert( this );
2323
}
2424

25-
MemoryLoop :: MemoryLoop(const char* fileName, unsigned long chunkSize){
26-
chunkSize_ = chunkSize;
27-
bool ok = memoryFS.open(fileName, chunkSize);
25+
MemoryLoop :: MemoryLoop(std::string fileName, unsigned long chunkSize)
26+
: FileLoop(chunkSize*10, chunkSize) {
27+
Stk::addSampleRateAlert( this );
28+
bool ok = memoryFS.open(fileName.c_str(), chunkSize);
2829
if (!ok){
29-
STK_LOGE("Could not find file: %s", fileName);
30+
STK_LOGE("Could not find file: %s", fileName.c_str());
3031
}
3132
}
3233

33-
MemoryLoop :: MemoryLoop(const char* fileName, const unsigned char *data, size_t size, unsigned long chunkSize ){
34-
chunkSize_ = chunkSize;
34+
MemoryLoop :: MemoryLoop(std::string fileName, const unsigned char *data, size_t size, unsigned long chunkSize )
35+
: FileLoop(chunkSize*10, chunkSize) {
3536
Stk::addSampleRateAlert( this );
36-
memoryFS.registerFile(fileName, data, size);
37+
memoryFS.registerFile(fileName.c_str(), data, size);
3738
this->openFile(fileName, true, true, true);
3839
}
3940

4041
MemoryLoop :: ~MemoryLoop( void ){
42+
Stk::removeSampleRateAlert( this );
4143
}
4244

4345
void MemoryLoop :: addPhaseOffset( StkFloat angle ){
@@ -97,7 +99,7 @@ void MemoryLoop ::open(bool doNormalize,bool doInt2FloatScaling) {
9799
// Set default rate based on file sampling rate.
98100
this->setRate( data_.dataRate() / Stk::sampleRate() );
99101

100-
if ( doNormalize & !chunking_ ) this->normalize();
102+
if ( doNormalize && !chunking_ ) this->normalize();
101103

102104
this->reset();
103105
}

src/MemoryLoop.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class MemoryLoop : public FileLoop {
3333
MemoryLoop(unsigned long chunkSize=256);
3434

3535
//! Class constructor that opens a specified file.
36-
MemoryLoop(const char* fileName, const unsigned char *data, size_t size, unsigned long chunkSize=256);
36+
MemoryLoop(std::string fileName, const unsigned char *data, size_t size, unsigned long chunkSize=1024);
3737

3838
//! Class constructor that opens a specified file. The file must have been registered
39-
MemoryLoop(const char* fileName, unsigned long chunkSize=256);
39+
MemoryLoop(std::string fileName, unsigned long chunkSize=1024);
4040

4141
//! Class destructor.
4242
~MemoryLoop( void );

src/MemoryWvIn.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
namespace stk {
77

88

9-
MemoryWvIn :: MemoryWvIn(unsigned long chunkSize){
10-
chunkSize_ = chunkSize;
9+
MemoryWvIn :: MemoryWvIn(unsigned long chunkSize)
10+
:FileWvIn(chunkSize*10,chunkSize){
1111
Stk::addSampleRateAlert( this );
1212
}
1313

14-
MemoryWvIn :: MemoryWvIn(const char* name, const unsigned char* raw, size_t size,unsigned long chunkSize){
15-
chunkSize_ = chunkSize;
14+
MemoryWvIn :: MemoryWvIn(std::string name, const unsigned char* raw, size_t size,unsigned long chunkSize)
15+
:FileWvIn(chunkSize*10,chunkSize){
1616
Stk::addSampleRateAlert( this );
17-
fs.registerFile(name,raw, size);
17+
fs.registerFile(name.c_str(),raw, size);
1818
openFile(name);
1919
}
2020

21-
MemoryWvIn :: MemoryWvIn(const char* name,unsigned long chunkSize ) {
22-
chunkSize_ = chunkSize;
21+
MemoryWvIn :: MemoryWvIn(std::string name,unsigned long chunkSize )
22+
:FileWvIn(chunkSize*10,chunkSize){
2323
Stk::addSampleRateAlert( this );
2424
openFile(name);
2525
}

src/MemoryWvIn.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ class MemoryWvIn : public FileWvIn
3737
/*!
3838
The file is also registed
3939
*/
40-
MemoryWvIn(const char* fileName, const unsigned char *data, size_t size, unsigned long chunkSize=256);
40+
MemoryWvIn(std::string fileName, const unsigned char *data, size_t size, unsigned long chunkSize=256);
4141

4242
//! Overloaded constructor for file input.
4343
/*!
4444
The file must have been registed before
4545
*/
46-
MemoryWvIn(const char* fileName, unsigned long chunkSize=256);
46+
MemoryWvIn(std::string fileName, unsigned long chunkSize=256);
4747

4848

4949
//! Class destructor.

src/Moog.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ Moog :: Moog( void )
3535

3636
#ifdef __RAW_ARRAYS__
3737
// Concatenate the STK rawwave path to the rawwave file
38-
attacks_.push_back( new MemoryWvIn( (Stk::rawwavePath() + "mandpluk.raw").c_str(), mandpluk_raw,mandpluk_raw_len ) );
39-
loops_.push_back ( new MemoryLoop( (Stk::rawwavePath() + "impuls20.raw").c_str(), impuls20_raw,impuls20_raw_len ) );
40-
loops_.push_back ( new MemoryLoop( (Stk::rawwavePath() + "sinewave.raw").c_str(), sinewave_raw,sinewave_raw_len ) ); // vibrato
38+
attacks_.push_back( new MemoryWvIn( (Stk::rawwavePath() + "mandpluk.raw"), mandpluk_raw,mandpluk_raw_len ) );
39+
loops_.push_back ( new MemoryLoop( (Stk::rawwavePath() + "impuls20.raw"), impuls20_raw,impuls20_raw_len ) );
40+
loops_.push_back ( new MemoryLoop( (Stk::rawwavePath() + "sinewave.raw"), sinewave_raw,sinewave_raw_len ) ); // vibrato
4141
#else
4242
// Concatenate the STK rawwave path to the rawwave file
43-
attacks_.push_back( new FileWvIn( (Stk::rawwavePath() + "mandpluk.raw").c_str(), true ) );
44-
loops_.push_back ( new FileLoop( (Stk::rawwavePath() + "impuls20.raw").c_str(), true ) );
45-
loops_.push_back ( new FileLoop( (Stk::rawwavePath() + "sinewave.raw").c_str(), true ) ); // vibrato
43+
attacks_.push_back( new FileWvIn( (Stk::rawwavePath() + "mandpluk.raw"), true ) );
44+
loops_.push_back ( new FileLoop( (Stk::rawwavePath() + "impuls20.raw"), true ) );
45+
loops_.push_back ( new FileLoop( (Stk::rawwavePath() + "sinewave.raw"), true ) ); // vibrato
4646
#endif
4747

4848

0 commit comments

Comments
 (0)