History

add wav file loading to test JUCE project

Matthew Wang committed 5 years ago

Commit 7ea48641 parent be773ed5 files · +65 −14Browse files

Showing the changes to TestPlugin/Source/MyTest.cpp (1 of 5 files). Show all

Unified · Split

TestPlugin/Source/MyTest.cpp+23−6
@@ -38,6 +38,9 @@ tWaveset ws; · 37 unmodified lines
3838 tBuffer samp;
3939 tMBSampler sampler;
4040
41+const int numWavetables = 1;
42+tWavetable wavetables[numWavetables];
43+
4144 float gain;
4245 float dtime;
4346 bool buttonState;
@@ -54,6 +57,8 @@ LEAF leaf; · 10 unmodified lines
5457 #define MSIZE 2048000
5558 char memory[MSIZE];
5659
60+int lastLoadedAudioSize = 0;
61+
5762 void LEAFTest_init (float sampleRate, int blockSize)
5863 {
5964 LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat);
@@ -79,6 +84,9 @@ void LEAFTest_init (float sampleRate, int blockSize) · 19 unmodified lines
7984
8085 tWaveset_init(&ws, set, 4, 2048, 10000.f, &leaf);
8186 tWaveset_setIndexGain(&ws, 0, -1.0f);
87+
88+ lastLoadedAudioSize = 0;
89+ loadedAudio.clear();
8290 }
8391
8492 inline double getSawFall(double angle) {
@@ -92,12 +100,12 @@ inline double getSawFall(double angle) { · 7 unmodified lines
92100
93101 float LEAFTest_tick (float input)
94102 {
95−// return tRetune_tick(&retune, input)[0];
96−// return tSimpleRetune_tick(&sretune, input);
97−// tMBPulse_sync(&bpulse, tPhasor_tick(&phasor) * 2.f - 1.f);
98−// return tMBPulse_tick(&bpulse);
99−// return tWavetable_tick(&wt);
100− return tWaveset_tick(&ws);
103+ float out = 0.0f;
104+ for (int i = 0; i < fmin(loadedAudio.size(), numWavetables); ++i)
105+ {
106+ out += tWavetable_tick(&wavetables[i]);
107+ }
108+ return out;
101109 }
102110
103111 int firstFrame = 1;
@@ -121,6 +129,15 @@ void LEAFTest_block (void) · 17 unmodified lines
121129 val = getSliderValue("slider3");
122130 // tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 2);
123131
132+
133+ if (lastLoadedAudioSize < loadedAudio.size())
134+ {
135+ int i = (loadedAudio.size() - 1) % numWavetables;
136+ if (loadedAudio.size() - 1 >= numWavetables) tWavetable_free(&wavetables[i]);
137+ tWavetable_init(&wavetables[i], loadedAudio[loadedAudio.size() - 1].getReadPointer(0), loadedAudio[loadedAudio.size() - 1].getNumSamples(), 20000, &leaf);
138+
139+ lastLoadedAudioSize = loadedAudio.size();
140+ }
124141 }
125142
126143 void LEAFTest_controllerInput (int cnum, float cval)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t