Mercurial > hg > beaglert
comparison examples/basic_FFT_phase_vocoder/render.cpp @ 301:e4392164b458 prerelease
RENAMED BeagleRT to Bela AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, scripts probably not working
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 27 May 2016 14:34:41 +0100 |
parents | dbeed520b014 |
children | 1feb9c23ac57 |
comparison
equal
deleted
inserted
replaced
300:dbeed520b014 | 301:e4392164b458 |
---|---|
4 * Created on: Oct 24, 2014 | 4 * Created on: Oct 24, 2014 |
5 * Author: parallels | 5 * Author: parallels |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include <BeagleRT.h> | 9 #include <Bela.h> |
10 #include <rtdk.h> | 10 #include <rtdk.h> |
11 #include <NE10.h> // NEON FFT library | 11 #include <NE10.h> // NEON FFT library |
12 #include <cmath> | 12 #include <cmath> |
13 #include "SampleData.h" | 13 #include "SampleData.h" |
14 #include <Midi.h> | 14 #include <Midi.h> |
98 | 98 |
99 // userData holds an opaque pointer to a data structure that was passed | 99 // userData holds an opaque pointer to a data structure that was passed |
100 // in from the call to initAudio(). | 100 // in from the call to initAudio(). |
101 // | 101 // |
102 // Return true on success; returning false halts the program. | 102 // Return true on success; returning false halts the program. |
103 bool setup(BeagleRTContext* context, void* userData) | 103 bool setup(BelaContext* context, void* userData) |
104 { | 104 { |
105 midi.readFrom(0); | 105 midi.readFrom(0); |
106 midi.setParserCallback(midiCallback); | 106 midi.setParserCallback(midiCallback); |
107 // Retrieve a parameter passed in from the initAudio() call | 107 // Retrieve a parameter passed in from the initAudio() call |
108 gSampleData = *(SampleData *)userData; | 108 gSampleData = *(SampleData *)userData; |
127 for(int n = 0; n < gFFTSize; n++) { | 127 for(int n = 0; n < gFFTSize; n++) { |
128 gWindowBuffer[n] = 0.5f * (1.0f - cosf(2.0 * M_PI * n / (float)(gFFTSize - 1))); | 128 gWindowBuffer[n] = 0.5f * (1.0f - cosf(2.0 * M_PI * n / (float)(gFFTSize - 1))); |
129 } | 129 } |
130 | 130 |
131 // Initialise auxiliary tasks | 131 // Initialise auxiliary tasks |
132 if((gFFTTask = BeagleRT_createAuxiliaryTask(&process_fft_background, 90, "fft-calculation")) == 0) | 132 if((gFFTTask = Bela_createAuxiliaryTask(&process_fft_background, 90, "fft-calculation")) == 0) |
133 return false; | 133 return false; |
134 rt_printf("You are listening to an FFT phase-vocoder with overlap-and-add.\n" | 134 rt_printf("You are listening to an FFT phase-vocoder with overlap-and-add.\n" |
135 "Use Midi Control Change to control:\n" | 135 "Use Midi Control Change to control:\n" |
136 "CC 2: effect type (bypass/robotization/whisperization)\n" | 136 "CC 2: effect type (bypass/robotization/whisperization)\n" |
137 "CC 3: mix between recorded sample and live audio input\n" | 137 "CC 3: mix between recorded sample and live audio input\n" |
202 | 202 |
203 // render() is called regularly at the highest priority by the audio engine. | 203 // render() is called regularly at the highest priority by the audio engine. |
204 // Input and output are given from the audio hardware and the other | 204 // Input and output are given from the audio hardware and the other |
205 // ADCs and DACs (if available). If only audio is available, numMatrixFrames | 205 // ADCs and DACs (if available). If only audio is available, numMatrixFrames |
206 // will be 0. | 206 // will be 0. |
207 void render(BeagleRTContext* context, void* userData) | 207 void render(BelaContext* context, void* userData) |
208 { | 208 { |
209 float* audioIn = context->audioIn; | 209 float* audioIn = context->audioIn; |
210 float* audioOut = context->audioOut; | 210 float* audioOut = context->audioOut; |
211 int numAudioFrames = context->audioFrames; | 211 int numAudioFrames = context->audioFrames; |
212 int numAudioChannels = context->audioChannels; | 212 int numAudioChannels = context->audioChannels; |
248 gSampleCount++; | 248 gSampleCount++; |
249 if(gSampleCount >= gHopSize) { | 249 if(gSampleCount >= gHopSize) { |
250 //process_fft(gInputBuffer, gInputBufferPointer, gOutputBuffer, gOutputBufferPointer); | 250 //process_fft(gInputBuffer, gInputBufferPointer, gOutputBuffer, gOutputBufferPointer); |
251 gFFTInputBufferPointer = gInputBufferPointer; | 251 gFFTInputBufferPointer = gInputBufferPointer; |
252 gFFTOutputBufferPointer = gOutputBufferWritePointer; | 252 gFFTOutputBufferPointer = gOutputBufferWritePointer; |
253 BeagleRT_scheduleAuxiliaryTask(gFFTTask); | 253 Bela_scheduleAuxiliaryTask(gFFTTask); |
254 | 254 |
255 gSampleCount = 0; | 255 gSampleCount = 0; |
256 } | 256 } |
257 } | 257 } |
258 gHopSize = gPeriod; | 258 gHopSize = gPeriod; |
259 } | 259 } |
260 | 260 |
261 // cleanup_render() is called once at the end, after the audio has stopped. | 261 // cleanup_render() is called once at the end, after the audio has stopped. |
262 // Release any resources that were allocated in initialise_render(). | 262 // Release any resources that were allocated in initialise_render(). |
263 | 263 |
264 void cleanup(BeagleRTContext* context, void* userData) | 264 void cleanup(BelaContext* context, void* userData) |
265 { | 265 { |
266 NE10_FREE(timeDomainIn); | 266 NE10_FREE(timeDomainIn); |
267 NE10_FREE(timeDomainOut); | 267 NE10_FREE(timeDomainOut); |
268 NE10_FREE(frequencyDomain); | 268 NE10_FREE(frequencyDomain); |
269 NE10_FREE(cfg); | 269 NE10_FREE(cfg); |