LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-27-2009, 06:26 AM   #1
maikki
LQ Newbie
 
Registered: Jan 2009
Location: Slovak Republic
Distribution: Ubuntu 10.4
Posts: 26

Rep: Reputation: 15
Changing sample rate of sound


Hi all

I know this is not exactly forum about sound but i need some help. Do you know any good algorithm, which should change e.g. speech rate? I have recorded speech and I need something to slow ti down or fasten it up. I know that audacity can do this but i have my application and I'd like to know how to work with sound. Do you know any idea or some algorithms to work with it?

thx.
 
Old 09-27-2009, 07:12 AM   #2
avalonit
Member
 
Registered: Jun 2008
Posts: 81

Rep: Reputation: 19
You mean, you want to implement such features for your app?

I'd suggest you look at the sources of audacity plug-ins as well LADSPA plug-ins that do these kinds of things.

Probably audacity dev list, alsa lists or such could give you more information.
 
Old 09-27-2009, 08:50 PM   #3
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
to do it the quick and dirty way:
to speed up the sample rate::duplicate samples
to slow it own::skip samples
 
Old 09-29-2009, 09:03 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by maikki View Post
Hi all

I know this is not exactly forum about sound but i need some help. Do you know any good algorithm, which should change e.g. speech rate? I have recorded speech and I need something to slow ti down or fasten it up. I know that audacity can do this but i have my application and I'd like to know how to work with sound. Do you know any idea or some algorithms to work with it?

thx.
Do you want mathematical background or do you want implementation ?

If the latter, for the whole sound system or, say, batch processing for files ?
 
Old 09-29-2009, 06:03 PM   #5
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by smeezekitty View Post
to do it the quick and dirty way:
to speed up the sample rate::duplicate samples
to slow it own::skip samples
I might be mistaken, but when you do this by adding or deleting samples, you are changing the pitch of the sound.

Imagine that you have a sine for which one period is described with 20 samples. If you play it by omitting every second sample, you play this sine in the same time, but only using 10 samples per period. 10 samples in the same time as previously held 20 samples with a constant sample rate really increases the frequency.

jlinkels
 
Old 09-29-2009, 06:06 PM   #6
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
but you change the tag to match saying to play it at half speed
 
Old 09-29-2009, 06:21 PM   #7
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Cool, then you have exactly the same speed of speech, just with half of the samples. What have you achieved?

jlinkels
 
Old 09-29-2009, 06:22 PM   #8
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
as for what the op wanted
the orignal method will work
nomatter how you change the speed of the sound
it will always change pitch too
 
Old 09-29-2009, 06:55 PM   #9
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
No, it does not. Modern software programs are able to chnage the speed without changing the pitch. I believe that is done by changing the sampling rate, and shifting the frequency by an equal amount in the frequency domain.

jlinkels
 
Old 09-29-2009, 07:08 PM   #10
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Isn't the OP simply wanting to speed up or slow down the playback rate? Kind of like spinning the LP disk faster or slower on the turntable? Digitized sound is basically a time ordered series of discreet samples. Accurate playback fidelity implies using the same conversion rate for the DAC as was used for the ADC in the recording phase. Not doing so will alter the pitch. Most digital sound files contain sample rate information, which can potentially be altered, such that the playback rate will differ from the recording rate. The exact format of the file will dictate what would need to be changed, and also what changes would be seen as valid. There may be tools which make this kind of editing simple, however with knowledge of the file format, one should be able to use a generic binary-style editor.

On the other hand, the original poster may be asking how to re-sample a recorded sound file. If the sound is re-sampled with fewer samples per unit of time, it will decrease both the file size and fidelity. If the sound is re-sampled with more samples per unit of time, it will increase the file size, but will not increase fidelity. A quick Google search for 'audio resampling algorithm' turned up numerous useful hits for me.

--- rod.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing sample rate for OSS? Elijah Linux - Hardware 2 04-27-2006 05:57 PM
emagic 2|6 outputs / sample rate rnton Linux - Hardware 0 04-08-2006 10:29 AM
Podcast Sample rate gmartin LQ Suggestions & Feedback 7 03-03-2006 02:58 PM
Wrong sample rate on optical out Misel Linux - Hardware 4 04-13-2005 03:53 AM
ps2 mouse sample rate citron Linux - General 0 09-18-2002 10:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration