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
38tBuffer samp;38tBuffer samp;
39tMBSampler sampler;39tMBSampler sampler;
40 40
41const int numWavetables = 1;
42tWavetable wavetables[numWavetables];
43
41float gain;44float gain;
42float dtime;45float dtime;
43bool buttonState;46bool buttonState;
@@ -54,6 +57,8 @@ LEAF leaf; · 10 unmodified lines
54#define MSIZE 204800057#define MSIZE 2048000
55char memory[MSIZE];58char memory[MSIZE];
56 59
60int lastLoadedAudioSize = 0;
61
57void LEAFTest_init (float sampleRate, int blockSize)62void LEAFTest_init (float sampleRate, int blockSize)
58{63{
59 LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat);64 LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat);
@@ -79,6 +84,9 @@ void LEAFTest_init (float sampleRate, int blockSize) · 19 unmodified lines
79 84
80 tWaveset_init(&ws, set, 4, 2048, 10000.f, &leaf);85 tWaveset_init(&ws, set, 4, 2048, 10000.f, &leaf);
81 tWaveset_setIndexGain(&ws, 0, -1.0f);86 tWaveset_setIndexGain(&ws, 0, -1.0f);
87
88 lastLoadedAudioSize = 0;
89 loadedAudio.clear();
82}90}
83 91
84inline double getSawFall(double angle) {92inline double getSawFall(double angle) {
@@ -92,12 +100,12 @@ inline double getSawFall(double angle) { · 7 unmodified lines
92 100
93float LEAFTest_tick (float input)101float LEAFTest_tick (float input)
94{102{
95// return tRetune_tick(&retune, input)[0];103 float out = 0.0f;
96// return tSimpleRetune_tick(&sretune, input);104 for (int i = 0; i < fmin(loadedAudio.size(), numWavetables); ++i)
97// tMBPulse_sync(&bpulse, tPhasor_tick(&phasor) * 2.f - 1.f);105 {
98// return tMBPulse_tick(&bpulse);106 out += tWavetable_tick(&wavetables[i]);
99// return tWavetable_tick(&wt);107 }
100 return tWaveset_tick(&ws);108 return out;
101}109}
102 110
103int firstFrame = 1;111int firstFrame = 1;
@@ -121,6 +129,15 @@ void LEAFTest_block (void) · 17 unmodified lines
121 val = getSliderValue("slider3");129 val = getSliderValue("slider3");
122// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 2);130// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 2);
123 131
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 }
124}141}
125 142
126void LEAFTest_controllerInput (int cnum, float cval)143void 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