react-native-sound icon indicating copy to clipboard operation
react-native-sound copied to clipboard

request: change tempo?

Open beebase opened this issue 9 years ago • 10 comments

Would it be possible to add a method for controlling tempo of sound file?

beebase avatar Apr 18 '16 11:04 beebase

I'm afraid that for the android side this is not possible with the current implementation, but I would be interested of this as well. MediaPlayer does not support it: http://stackoverflow.com/questions/10849961/speed-control-of-mediaplayer-in-android

nielsswinkels avatar May 04 '16 09:05 nielsswinkels

And then 3 days after my previous comment someone adds the answer that it is now possible from api 23: http://stackoverflow.com/questions/10849961/speed-control-of-mediaplayer-in-android/37094353#37094353

nielsswinkels avatar Aug 19 '16 08:08 nielsswinkels

Are there updates here?

ninamanalo19 avatar Oct 20 '16 09:10 ninamanalo19

PR #63 has been merged, so we have iOS-only support for this. Perhaps a helpful person will make a PR for the Android side - should be pretty straightforward.

benvium avatar Feb 09 '17 09:02 benvium

I think there is a misunderstanding, tempo is not the note speed (pitch), it's the speed of a sequence of notes, so I don't see the link with the PR 63. Do we have the ability with this implementation to play timely accurate sequence of notes (tempo) ? I do not find how.

Thank you

sekiwired avatar Apr 26 '17 15:04 sekiwired

Any update on this?

DanNi0130 avatar May 05 '17 19:05 DanNi0130

The setSpeed function might actually be the solution to this issue.

The setSpeed function allows to play a file faster/slower (at higher/lower tempo) while doing pitch correction so that playing faster does not cause higher pitches.

(now also in the android version as per https://github.com/zmxv/react-native-sound/pull/169)

twitwi avatar May 13 '17 18:05 twitwi

I found a solution for android but don't know how to add in react native sound. I think this should be able to change the sound to chipmunk sound.

from Set pitch of a song being played in Android MediaPlayer

String recordingPath = recordingDirectory + File.separator + "music.mp3";
MediaPlayer audioPlayer = MediaPlayer.create(getApplicationContext(), Uri.parse(recordingPath));
audioPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
PlaybackParams params = new PlaybackParams();
params.setPitch(0.75f);
audioPlayer.setPlaybackParams(params);
audioPlayer.start();

and another from IOS Change Pitch Rate of Sound in Swift - XCode 6.4 and this Changing Voice Pitch using AVAudioPlayer

hope this can help someone to commit new version with these features

kkusanagi avatar Feb 08 '18 18:02 kkusanagi

@kkusanagi I just added a PR #466 to support setPitch(float). Maybe a little late for your requirement, but still feel free to check it out.

ketn avatar Jul 21 '18 17:07 ketn

did pitch get added for iOS too?

Fahad-pnw avatar Aug 22 '23 23:08 Fahad-pnw