Difficulty with beginPitchShift

tejas

Member
Hello!

I am trying a simple project where I want to change the pitch of audio from mic input of Teensy audio shield, and send it out via the headphone jack of the shield. My code is attached.

I am unable to hear any audio. However, the moment I uncomment the only line in the loo(), I can hear the mic input directly into the headphones. Am I doing something wrong in the way I'm using the beginPitchShift() function?

Thanks a bunch in advance!
Tejas

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputI2S i2s2; //xy=105,90
AudioMixer4 mixer1; //xy=230,103
AudioEffectGranular granular1; //xy=363,103
AudioOutputI2S i2s1; //xy=507,102
AudioConnection patchCord1(i2s2, 0, mixer1, 0);
AudioConnection patchCord2(i2s2, 1, mixer1, 1);
AudioConnection patchCord3(mixer1, granular1);
AudioConnection patchCord4(granular1, 0, i2s1, 0);
AudioConnection patchCord5(granular1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=506,150
// GUItool: end automatically generated code

#define GRANULAR_MEMORY_SIZE 12800 // enough for 290 ms at 44.1 kHz
int16_t granularMemory[GRANULAR_MEMORY_SIZE];

void setup() {
AudioMemory(32);
sgtl5000_1.enable();
sgtl5000_1.volume(0.8);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(50);

mixer1.gain(0, 0.5);
mixer1.gain(1, 0.5);

granular1.begin(granularMemory, GRANULAR_MEMORY_SIZE);
}

void loop() {
granular1.beginPitchShift(50);
granular1.setSpeed(1.0);
}
 
Perhaps the granular synth object doesn't pass any signal by default. You signal has to go through it to appear at the output...
 
These lines only need to run once, for example during setup:
granular1.beginPitchShift(50);
granular1.setSpeed(1.0);

Also, speed 1.0 plays back the input at the original rate right?. Set it to for example 2.0 to hear interesting things.
 
Perhaps the granular synth object doesn't pass any signal by default. You signal has to go through it to appear at the output...
The signal is going through the granular object, and I do hear it the moment I comment the following line.
granular1.beginPitchShift(50);
However, when the line is uncommented, I hear nothing.

Here is how the flow looks.

Screen Shot 2023-12-26 at 12.23.35 PM.png
 
These lines only need to run once, for example during setup:
granular1.beginPitchShift(50);
granular1.setSpeed(1.0);

Also, speed 1.0 plays back the input at the original rate right?. Set it to for example 2.0 to hear interesting things.
That did the trick! Thanks for the suggestion. :)
 
Back
Top