belaplatform / bela-online-course Goto Github PK
View Code? Open in Web Editor NEWAssets and slides for the free YouTube course, C++ Real-time Audio Programming with Bela, released in Spring 2020.
Assets and slides for the free YouTube course, C++ Real-time Audio Programming with Bela, released in Spring 2020.
I've went over the code in the lecture three times and I can't see any difference between the slides in the lecture and what I'm running on my Bela. When the code runs on my Bela the sample in the delay buffer is identical to the sample from the input, so there is no delay between the left and right channels. The code below is a copy + paste from the IDE on my computer.
I'm reading the relevant code and it looks like when gWritePointer is 0, this sets index 0 to the same value as the input, then increments gWritePointer. If this is actually what is happening I understand why I hear the same thing in the left and right channels. Otherwise, I don't understand why I don't hear a delayed signal in the left channel.
#include <Bela.h>
#include <vector>
#include "MonoFilePlayer.h"
// Name of the sound file (in project folder)
std::string gFilename = "slow-drum-loop.wav";
// Object that handles playing sound from a buffer
MonoFilePlayer gPlayer;
// TODO: declare variables for circular buffer
std::vector<float> gDelayBuffer;
unsigned int gWritePointer = 0;
bool setup(BelaContext *context, void *userData)
{
// Load the audio file
if(!gPlayer.setup(gFilename)) {
rt_printf("Error loading audio file '%s'\n", gFilename.c_str());
return false;
}
// Print some useful info
rt_printf("Loaded the audio file '%s' with %d frames (%.1f seconds)\n",
gFilename.c_str(), gPlayer.size(),
gPlayer.size() / context->audioSampleRate);
gDelayBuffer.resize(0.5 * context->audioSampleRate);
rt_printf("DelayBuffer is %d samples long\n", gDelayBuffer.size());
return true;
}
void render(BelaContext *context, void *userData)
{
for(unsigned int n = 0; n < context->audioFrames; n++) {
float in = gPlayer.process();
// TODO: your circular buffer code goes here
float out = gDelayBuffer[gWritePointer];
gDelayBuffer[gWritePointer] = in;
gWritePointer++;
if(gWritePointer >= gDelayBuffer.size());
gWritePointer = 0;
// Write the input and output to different channels
audioWrite(context, n, 0, in);
audioWrite(context, n, 1, out);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.