• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

お試しプログラム


Commit MetaInfo

修訂0a32b00d8c125aa4ab57f316fb3629607195fcc6 (tree)
時間2013-09-28 11:39:07
作者sambuichi <sambuichi@gmai...>
Commitersambuichi

Log Message

Instrmntのシミュレーションテストを追加

Change Summary

差異

--- a/c/stk/stk-sim-test/Makefile
+++ b/c/stk/stk-sim-test/Makefile
@@ -4,7 +4,9 @@ TARGET := run
44 DEFS := -D__MACOSX_CORE__
55 OBJS := main.o Stk.o SimDelay.o \
66 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
810
911 OBJS := $(patsubst %,obj/%,$(OBJS))
1012 vpath %.cpp ../stk-4.4.3/src
--- /dev/null
+++ b/c/stk/stk-sim-test/SimInst.cpp
@@ -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+
--- /dev/null
+++ b/c/stk/stk-sim-test/SimInst.h
@@ -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+
--- a/c/stk/stk-sim-test/main.cpp
+++ b/c/stk/stk-sim-test/main.cpp
@@ -4,18 +4,20 @@
44 #include <Stk.h>
55
66 #include "SimDelay.h"
7+#include "SimInst.h"
78
89 #define SAMPLING_RATE 48000
910 #define FRAME_LEN 320
1011
1112 using namespace stk;
1213
13-int main (int argc, char *argv[])
14+void test()
1415 {
1516 static FILE *fhOutPcm;
1617 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;
1921
2022 if((fhOutPcm = fopen("out.pcm", "wb")) == NULL) {
2123 fprintf(stderr, "file open error.");
@@ -24,8 +26,17 @@ int main (int argc, char *argv[])
2426 Stk::setSampleRate(SAMPLING_RATE);
2527
2628 while(counter++ < SAMPLING_RATE * simSec) {
27- StkFloat lastSample = sim.tick();
29+ //StkFloat lastSample = sim_delay.tick();
30+ StkFloat lastSample = sim_inst.tick();
2831 short lastShort = (short)(lastSample * SHRT_MAX);
2932 fwrite(&lastShort, sizeof(short), 1, fhOutPcm);
3033 }
3134 }
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+}
--- /dev/null
+++ b/c/stk/stk-sim-test/sim.sh
@@ -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