お試しプログラム
Revisión | 0a32b00d8c125aa4ab57f316fb3629607195fcc6 (tree) |
---|---|
Tiempo | 2013-09-28 11:39:07 |
Autor | sambuichi <sambuichi@gmai...> |
Commiter | sambuichi |
Instrmntのシミュレーションテストを追加
@@ -4,7 +4,9 @@ TARGET := run | ||
4 | 4 | DEFS := -D__MACOSX_CORE__ |
5 | 5 | OBJS := main.o Stk.o SimDelay.o \ |
6 | 6 | SineWave.o ADSR.o Delay.o DelayA.o \ |
7 | - FileWrite.o FileWvOut.o | |
7 | + FileWrite.o FileWvOut.o \ | |
8 | + SimInst.o FM.o HevyMetl.o TwoZero.o FileLoop.o FileWvIn.o FileRead.o \ | |
9 | + Mandolin.o PercFlut.o Plucked.o Flute.o OneZero.o OnePole.o PoleZero.o Twang.o DelayL.o Fir.o Noise.o | |
8 | 10 | |
9 | 11 | OBJS := $(patsubst %,obj/%,$(OBJS)) |
10 | 12 | vpath %.cpp ../stk-4.4.3/src |
@@ -0,0 +1,23 @@ | ||
1 | +#include "SimInst.h" | |
2 | + | |
3 | +SimInst::SimInst() : mFlute(20), mMandolin(20) | |
4 | +{ | |
5 | + mHevyMetl.noteOn(220, 1.0); | |
6 | + mMandolin.noteOn(220, 1.0); | |
7 | + mPlucked.noteOn(220, 1.0); | |
8 | + mPercFlut.noteOn(220, 1.0); | |
9 | + mFlute.noteOn(220, 1.0); | |
10 | +} | |
11 | + | |
12 | +SimInst::~SimInst() | |
13 | +{ | |
14 | + | |
15 | +} | |
16 | + | |
17 | +double SimInst::tick() | |
18 | +{ | |
19 | + double value = mHevyMetl.tick(); | |
20 | + | |
21 | + return value; | |
22 | +} | |
23 | + |
@@ -0,0 +1,27 @@ | ||
1 | +#ifndef __SIM_INST__ | |
2 | +#define __SIM_INST__ | |
3 | + | |
4 | +#include "HevyMetl.h" | |
5 | +#include "Mandolin.h" | |
6 | +#include "PercFlut.h" | |
7 | +#include "Plucked.h" | |
8 | +#include "Flute.h" | |
9 | + | |
10 | +class SimInst { | |
11 | +public: | |
12 | + SimInst(); | |
13 | + ~SimInst(); | |
14 | + | |
15 | + double tick(); | |
16 | + | |
17 | +private: | |
18 | + stk::HevyMetl mHevyMetl; | |
19 | + stk::Mandolin mMandolin; | |
20 | + stk::PercFlut mPercFlut; | |
21 | + stk::Plucked mPlucked; | |
22 | + stk::Flute mFlute; | |
23 | +}; | |
24 | + | |
25 | +#endif // __SIM_INST__ | |
26 | + | |
27 | + |
@@ -4,18 +4,20 @@ | ||
4 | 4 | #include <Stk.h> |
5 | 5 | |
6 | 6 | #include "SimDelay.h" |
7 | +#include "SimInst.h" | |
7 | 8 | |
8 | 9 | #define SAMPLING_RATE 48000 |
9 | 10 | #define FRAME_LEN 320 |
10 | 11 | |
11 | 12 | using namespace stk; |
12 | 13 | |
13 | -int main (int argc, char *argv[]) | |
14 | +void test() | |
14 | 15 | { |
15 | 16 | static FILE *fhOutPcm; |
16 | 17 | static unsigned int counter = 0; |
17 | - static unsigned int simSec = 1; | |
18 | - static SimDelay sim; | |
18 | + static unsigned int simSec = 5; | |
19 | + //static SimDelay sim_delay; | |
20 | + static SimInst sim_inst; | |
19 | 21 | |
20 | 22 | if((fhOutPcm = fopen("out.pcm", "wb")) == NULL) { |
21 | 23 | fprintf(stderr, "file open error."); |
@@ -24,8 +26,17 @@ int main (int argc, char *argv[]) | ||
24 | 26 | Stk::setSampleRate(SAMPLING_RATE); |
25 | 27 | |
26 | 28 | while(counter++ < SAMPLING_RATE * simSec) { |
27 | - StkFloat lastSample = sim.tick(); | |
29 | + //StkFloat lastSample = sim_delay.tick(); | |
30 | + StkFloat lastSample = sim_inst.tick(); | |
28 | 31 | short lastShort = (short)(lastSample * SHRT_MAX); |
29 | 32 | fwrite(&lastShort, sizeof(short), 1, fhOutPcm); |
30 | 33 | } |
31 | 34 | } |
35 | + | |
36 | +int main (int argc, char *argv[]) | |
37 | +{ | |
38 | + stk::Stk::setRawwavePath("../stk-4.4.3/rawwaves/"); | |
39 | + stk::Stk::setSampleRate(SAMPLING_RATE); | |
40 | + | |
41 | + test(); | |
42 | +} |
@@ -0,0 +1,3 @@ | ||
1 | +./run | |
2 | +sox -t raw -r48000 -c1 -b16 -e signed-integer out.pcm -t wav out.wav | |
3 | +open out.wav | |
\ No newline at end of file |