can calculate frame/block size correctly for at least 512 and 128 frames per chunk
This commit is contained in:
parent
98ab957faf
commit
fa30594239
@ -97,9 +97,6 @@ void Chassis::loadProgram(uint32_t index) {
|
|||||||
void Chassis::activate() {
|
void Chassis::activate() {
|
||||||
// calculate filter coefficients and stuff
|
// calculate filter coefficients and stuff
|
||||||
printf("called activate()\n");
|
printf("called activate()\n");
|
||||||
s.updateLength = sampleRate / 238; // update rate in Hz;
|
|
||||||
printf("update length is %d for %dHz sample rate\n", s.updateLength, (int)sampleRate);
|
|
||||||
//s.samplesLeft = s.updateLength;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chassis::deactivate() {
|
void Chassis::deactivate() {
|
||||||
@ -139,29 +136,31 @@ void Chassis::noteOff(uint8_t note) {
|
|||||||
void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEvent *MidiEvents, uint32_t midiEventCount) {
|
void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEvent *MidiEvents, uint32_t midiEventCount) {
|
||||||
// if (midiEventCount > 0) printf("\n--------------------\n");
|
// if (midiEventCount > 0) printf("\n--------------------\n");
|
||||||
|
|
||||||
//uint32_t framesDone = 0;
|
|
||||||
/*
|
if (s.framesLeft == 0) s.framesLeft = frames;
|
||||||
if (s.samplesLeft == 0) {
|
|
||||||
printf("resetting s.samplesLeft to %d\n", frames);
|
while ( s.framesLeft != 0) {
|
||||||
s.samplesLeft = frames;
|
uint32_t sizeThisTime = (frames <= s.blockLeft)?frames:s.blockLeft;
|
||||||
}*/
|
|
||||||
|
printf("sL = %d bL = %d, calculating %d frames\n", s.framesLeft, s.blockLeft, sizeThisTime);
|
||||||
|
|
||||||
|
|
||||||
printf("in run(%d), samplesLeft = %d\n", frames, s.samplesLeft);
|
s.framesLeft -= sizeThisTime;
|
||||||
s.samplesLeft = frames;
|
s.blockLeft -= sizeThisTime;
|
||||||
|
if (s.blockLeft == 0) {
|
||||||
|
s.blockLeft = 48000/238;
|
||||||
|
printf("compute params and reset block size\n");
|
||||||
|
}
|
||||||
|
if (s.framesLeft <= s.blockLeft) {
|
||||||
|
s.blockLeft -= s.framesLeft;
|
||||||
|
printf("ended with %d frames, %d left in block\n", s.framesLeft, s.blockLeft);
|
||||||
|
s.framesLeft = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
do {
|
//printf("done with all that, %d\n", s.samplesLeft);
|
||||||
printf("doing %d frames %d\n", s.updateLength, s.samplesLeft);
|
|
||||||
s.samplesLeft -= s.updateLength;
|
|
||||||
|
|
||||||
} while (s.samplesLeft > s.updateLength);
|
|
||||||
printf("doing %d frames %d\n", s.samplesLeft, s.samplesLeft);
|
|
||||||
s.samplesLeft = s.updateLength - s.samplesLeft;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printf("done with all that, %d\n", s.samplesLeft);
|
|
||||||
|
|
||||||
|
printf("and now run the rest of the process for %d frames\n\n", frames);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < midiEventCount; i++) {
|
for (uint32_t i = 0; i < midiEventCount; i++) {
|
||||||
if (MidiEvents[i].data[0] == 0x90) {
|
if (MidiEvents[i].data[0] == 0x90) {
|
||||||
@ -180,6 +179,7 @@ void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEv
|
|||||||
s.lastpw = s.lfo;
|
s.lastpw = s.lfo;
|
||||||
// copy left to right
|
// copy left to right
|
||||||
memmove(outputs[1], outputs[0], sizeof(float) * frames);
|
memmove(outputs[1], outputs[0], sizeof(float) * frames);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the plugin
|
// create the plugin
|
||||||
|
@ -59,6 +59,6 @@ class Synth {
|
|||||||
Voice voice[8];
|
Voice voice[8];
|
||||||
float lfo = 0, lfosw = 0.01;
|
float lfo = 0, lfosw = 0.01;
|
||||||
float lastpw = 0;
|
float lastpw = 0;
|
||||||
uint32_t updateLength;
|
uint32_t blockLeft;
|
||||||
uint32_t samplesLeft = 0;
|
uint32_t framesLeft = 0;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user