Changing speed of a sound file
来源:互联网 发布:淘宝如何参加公益宝贝 编辑:程序博客网 时间:2024/06/01 08:34
原文地址:http://stackoverflow.com/questions/939904/changing-speed-of-a-sound-file
There are two options to speed up the playback of a sound file:
- Increase the sample rate
- Reduce the number of samples per unit of time.
In either of these methods, the increase in playback speed will have a corresponding change in the pitch of the sound.
Increasing the sample rate
Increasing the sample rate will increase the playback speed of the sound. For example, going from a 22 KHz sampling rate to 44 KHz will make the playback sound twice as fast as the original. In this method, the original sampling data is unaltered -- only the audio playback settings need to be changed.
Reduce the number of samples per unit of time
In this method, the playback sampling rate is kept constant, but the number of samples are reduced -- some of the samples are thrown out.
The naive approach to make the playback of the sound be twice the speed of the original is to remove every other sample, and playback at the original playback sampling rate.
However, with this approach, some of the information will be lost, and I would expect that some artifacts will be introduced to the audio, so it's not the most desirable approach.
Although I haven't tried it myself, the idea of averaging the samples to create a new sample to be a good approach to start with. This would seem to mean that rather than just throwing out audio information, it can be "preserved" to an extent by the averaging process.
As a rough idea of the process, here's a piece of pseudocode to double the speed of playback:
original_samples = [0, 0.1, 0.2, 0.3, 0.4, 0.5]def faster(samples): new_samples = [] for i = 0 to samples.length: if i is even: new_samples.add(0.5 * (samples[i] + samples[i+1])) return new_samplesfaster_samples = faster(original_samples)
I've also posted an answered to the a question "Getting started with programmatic audio" where I went into some details about some basic audio manipulation that can be performed, so maybe that might be of interest as well.
- Changing speed of a sound file
- Listen to 'Speed Of Sound' this Monday!
- 7.Integrated Knowledge: changing acceleration to speed and speed to distance — an example of integra
- Changing the sharing of a project
- Test The Speed of .sdf file
- Playing a wave sound from a resource file
- chmod: changing permissions of '/etc/passwd': Read-only file system
- chmod: changing permissions of ‘/etc/passwd': Read-only file system
- Changing a process’ file descriptor on the fly
- Changing the Title of a Print Dialog in Delphi
- Changing the layout direction of a form item in Flex
- Changing the rendering mode of a shared page
- The Sound of Silence
- The Sound Of Silence
- The sound of silence
- Sound Of Silence
- Sound of silence
- The sound of music
- 四大组件相关知识点
- 快排优化Python表示
- linux下QTE环境搭建
- java画棋盘
- BeaEngine.lib VS2015 链接问题
- Changing speed of a sound file
- java中ServletContext的作用和常见获取方法
- 第七天 广播接受者
- 【Android 学习笔记】之 Material design
- Win10下VS2015(WDK10)驱动开发环境配置
- eclipse里面的@SuppressWarnings({ "unchecked", "rawtypes" })
- 安装SVN提示please wait while the installer finishes determining your disk space requirements
- 搭建maven开发环境
- Android屏幕适配全攻略(最权威的官方适配指导)