PDA

View Full Version : Changing Pitch of Voice



lerxstrulz
08-21-2016, 01:21 AM
Hi All,

I have a project where I would like to be able to adjust the pitch of a person's voice. I have tried using the Filter and different values for octaveControl and resonance, but it seems to just end up sounding kinda muffled at the same pitch (I'm probably doing it wrong ;) )

Is there are way with one of the filters (or another method) to take someone's voice and either raise or lower the pitch on output?

Thanks!

- Brent

PaulStoffregen
08-21-2016, 06:51 AM
I believe term is "phase vocoder".

It's on my list of things to try with the new Teensy 3.6...

lerxstrulz
08-21-2016, 07:10 AM
I believe term is "phase vocoder".

It's on my list of things to try with the new Teensy 3.6...

Ooooooh! :D

PaulStoffregen
08-25-2016, 02:36 AM
This is the algorithm I intend to try first. Of course, first need to get through this Kickstarter...

http://www.guitarpitchshifter.com/pitchshifting.html

FlySpray
09-11-2016, 09:40 AM
I'm very new to the Audio Library. so could be very wrong here..

Wouldn't the SINE_FM object in the Audio Library achieve this effect?
by modulating the incoming voice waveform against a sine wav?

This should increase/decrease the pitch i think.

PaulStoffregen
09-11-2016, 03:51 PM
by modulating the incoming voice waveform against a sine wav?


That will modulate a sine wave's frequency by the incoming waveform. The result will be pretty much a sine wave that fluctuates in tone. Probably not what you want.

lerxstrulz
11-01-2016, 03:08 PM
I believe term is "phase vocoder".

It's on my list of things to try with the new Teensy 3.6...

Hey Paul...just wondering if this is still in the queue? ;)

hyperdyne
11-17-2016, 01:58 AM
My pitch shifter is running on the Teensy 3.2 in real time, with gobs of cycles to spare. So it is certainly doable...

lerxstrulz
11-17-2016, 05:11 PM
My pitch shifter is running on the Teensy 3.2 in real time, with gobs of cycles to spare. So it is certainly doable...

Is this code you've written for the Teensy or hardware?

hyperdyne
11-17-2016, 07:29 PM
I don't understand your question. It is for the teensy, I've had to create lots of custom audio functions since the library was lacking.

lerxstrulz
11-17-2016, 07:31 PM
I don't understand your question. It is for the teensy, I've had to create lots of custom audio functions since the library was lacking.

I was asking whether you had written custom code (software) for the Teensy or if you had implemented a hardware solution to accomplish the pitch change. Thank you for the answer.

PaulStoffregen
11-17-2016, 07:33 PM
I've had to create lots of custom audio functions since the library was lacking.

Any chance you might share some of these improvements?

hyperdyne
11-17-2016, 07:34 PM
Oh ok. yes I wrote CPP code for the teensy 3.2

hyperdyne
11-17-2016, 09:25 PM
Any chance you might share some of these improvements?

As of right now I have a full band audio compressor that is ready for public consumption. Are you interested in that? I use it to compress the audio output when multiple sounds are being played out so you dont get that nasty overflow popping.

PaulStoffregen
11-18-2016, 02:04 PM
Yes, very interested.

hyperdyne
11-18-2016, 06:34 PM
Ok, let me know if you have a preference on sending. I guess I can zip it up and post the code here...

hyperdyne
11-18-2016, 10:58 PM
Ok here is the full-band compressor. It can also act as a limiter if you make compression ratio P large (like P>=40)

Also you can use the peak or rms block to regularly update the compression gain.

hyperdyne
11-18-2016, 11:23 PM
Here is a simple vocal compressor ex using the input mic. Comp ratio set to 4.



/*
c
* Vocal compression example
* Author: J. Shima
*
- released

The audio board uses the following pins.
6 - MEMCS
7 - MOSI
9 - BCLK
10 - SDCS
11 - MCLK
12 - MISO
13 - RX
14 - SCLK
15 - VOL
18 - SDA
19 - SCL
22 - TX
23 -
*/

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

// Use these with the audio adaptor board
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14

const int myInput = AUDIO_INPUT_MIC;
//const int myInput = AUDIO_INPUT_LINEIN;

// GUItool: begin automatically generated code
AudioInputI2S audioInput;
AudioAnalyzeRMS rms;
AudioEffectCompressor compress;
AudioOutputI2S audioOutput;

AudioConnection patchCord1(audioInput, 0, rms, 0);
AudioConnection patchCord2(audioInput, 0, compress, 0);
AudioConnection patchCord3(compress, 0, audioOutput, 0);
AudioConnection patchCord4(compress, 0, audioOutput, 1);
AudioControlSGTL5000 audioShield;

#define ALPHA 0.8 // time constant of 45ms

//
//---- Global variables -----
float rms_cur;
float env = 0;
unsigned long last_time = millis();
int cnt = 0;

//================ main loop ==============================
void loop()
{

// timer loop at 10ms
while(millis() - last_time < 10);

last_time = millis();

//update env (pwr) for compressor
if(rms.available())
{
rms_cur = rms.read();
env = rms_cur + ALPHA*(env - rms_cur);

compress.update_pwr( env ); //update compressor cN est
}

if(++cnt >= 100) //every sec
{
cnt = 0;
Serial.print("Comp gain: ");
Serial.println(compress.get_gain());
}

} //loop


//------------ Init routine ---------------
void setup()
{
int waitcnt;

Serial.begin(9600);
delay(300);

// ----------------------
AudioMemory(10);
audioShield.enable();
audioShield.inputSelect(myInput);
audioShield.volume(0.5);

compress.begin(1, 0.5, 4); //en, thresh c0, comp ratio p

SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN)))
{
waitcnt = 0;
// stop here, but print a message repetitively
while (1)
{
Serial.println("Unable to access the SD card");

if(++waitcnt >= 5)
{
Serial.println("Could not find SD card, continuing....");
break;
}
}
}

Serial.println("setup done");

} //setup()

lerxstrulz
01-17-2017, 11:18 PM
Any chance you would share the pitch shifting code? ;)

chipaudette
01-18-2017, 03:41 AM
Here is a simple vocal compressor ex using the input mic. Comp ratio set to 4.


If you've got a Teensy 3.5 or 3.6, you can also use the dynamic range compressor in my floating-point extension of the Teensy Audio Library. You can check out a write-up here, with example code:

http://openaudio.blogspot.com/2017/01/basic-dynamic-range-compressor.html

Chip

omjanger
02-03-2017, 03:56 PM
My pitch shifter is running on the Teensy 3.2 in real time, with gobs of cycles to spare. So it is certainly doable...

How did you implement the picth shifter? What kind of algorithm. And is it changing the pitch both up or down?

tenkai
06-03-2017, 11:25 PM
hey @hyperdyne, would love to see your pitch shifting code added to the teensy audio lib :D

yihanhu
02-28-2018, 05:41 PM
Hi i know it is probably a lot to ask but is there any chance that you have shared the pitch shifting code?

yihanhu
02-28-2018, 05:45 PM
Hi Paul, i'm totally new to Teensy and it would really help me if you could explain some questions here regarding this project.
Is the teensy audio library referring to the functions on audio design tool?
Has the audio library been updated with a pitch shifting code yet?
thank you so much!!

el_supremo
02-28-2018, 05:46 PM
Is the teensy audio library referring to the functions on audio design tool?
Yes.


Has the audio library been updated with a pitch shifting code yet?
No.

Pete

PaulStoffregen
02-28-2018, 10:48 PM
There's a big difference between dynamic range compression and real time pitch shifting (link in message #4).

Quite a number of other "voice changing" effects are also possible without these. Here's one that's pretty awesome.


https://www.youtube.com/watch?v=2TyN__5MuJs