I am developing a Soundboard application. I use MediaPlayer to Play Ogg sound files. Now when I switch from one sound to another sound, I get a noise similar to the ones heard while switching radio stations. I do not want this noise. How to eliminate it? Any Ideas? Thank You
Probably a silly answer but try adjusting the volume level to the lowest possible before making the switch, then resetting back to the user's original level when completed - sorry.
I found out. It was because of the conversion of the files from mp3 to ogg. MP3 files were of higher bitrate and when converted to ogg ended up in the loss of quality which resulted in the noise.
Related
So I have an app where mp3 file is being played using the MediaPlayer. On most devices everything is fine but on Samsung and some other (like HTC One S) devices the same mp3 plays "too fast" (skipping gaps): looks like player does not handle sound gaps (silence) correctly. These mp3s are just speech and speech naturally has gaps (silence) between spoken words. And these gaps are not played correctly in terms of time - MediaPlayer just skips them. As result mp3 is played faster by the duration of all gaps it contains.
What could be a reason and solution for this?UPDATEI'd found that its about frequency+VBR. Somehow if mp3 is of 22050/24000/32000 Hz instead of 44100 or 48000 and VBR or ABR is used the issue raises up. Im using LAME for mp3 encoding. If I remove "--resample 22.05" option so the resulting mp3 becomes 44.1kHz there is no issue playing this mp3 on samsung phone. However the resulting size of mp3 becomes twice bigger which is not acceptable for me cuz in this case my apk becomes bigger than 50Mb. So now the question is how to properly compress mp3 as 22kHz/VBR/MONO.
The issue was fixed in the following way: I added a white noise to an original sound and then encoded it to MP3 format. Resulting files became bigger in size but also they become more compatible (with Samsung devices) The original audio file (made at recording studio) is too clean meaning that silence/pauses in speech (between pronounced words) has no waveform if look in sound editor, its like an ideal silence. So on variuos Samsung devices such MP3-encoded files played with described issue. However on most other devices and PCs such MP3 files played just fine. Once again - Samsung "rules"!
You need to Google our for controlling playback speed in your application I mean to say that there must be some sort of 'playback rate' variable which must be a floating point value something between 0 to 1. This might help you in some workarounds for your app hope you find this somewhat helpful in anyway . O by the way here are some useful links that might help you out as well and if not then we have to keep waiting in the waiting queue for Samsung ;-) if its specifically related to them happy coding
http://code.google.com/p/android/issues/detail?id=1961
play an mp3 with MediaPlayer class on Android issues
Regards
Anas.
I am doing a cards game for android and I want that everytime a card is thrown, to play throwing sound. It is the same file. I will have also other sounds playing like background music , and certain clicks.
What do you recommend to use, sound pool or create MediaPlayback and play it? What would be the advantage/disdvantage to each one? should I use ogg or mp3/wave file?
Any help in this is appreciated.
Thank you
I would use the sound pool for short clips. I might be wrong but the sound pool has a smaller overhead plus it's the correct way to play short clips, it also allows you to specify how many times per second said sound clip can play which helps slower phones.
With regards to the mp3 vs ogg I use mp3. I don't believe there is any performance issues. Ogg is licence free but that doesn't really matter with regards to your app. Plus it might help if you plan on using these clips on another platform that doesn't play ogg files. No names mentioned :P
I'm creating an app where I need to load OGG audio files into a SoundPool, but it must be compatible with Android 2.1 (which does NOT support onLoadingCompleteSetListener). Because of this, there's no way to tell if the sound file is loaded before playing it.
To bypass this, I put a Thread.sleep(1000); right after loading the audio file to give it some time to load. But now without the onLoadingCompleteSetListener method, my audio files are extremely static-y and unclear. It sounds horrible. But I'm not getting the "sample # not ready!" warning in LogCat so I think the Thread.sleep(1000); is doing its job.
But does Thread.sleep(1000); also stop the loading process? So actually I'm not giving it time to load and that's why it's static-y? I can't figure this out, I just need my audio to be clearer. Any suggestions could help.
Thanks!
Solved myself, used Audacity to normalize and compress the audio files after learning about it from the answer in another one of my questions: Audio Sound Too Low in Android App
Fixed all the static
how to fast forwarding an Audio file using media player in android on seekbar progress change?
I would use the 'seekTo()'-method and jump about 10 or 20 seconds each time.
I don't think MediaPlayer can do much more than play/pause actually. I'm using SoundPool non-stop, so someone should correct me if I'm wrong here.
I think you might need to add different versions of the song (with different speed) and change the actual source each time you want to speed up.
I am playing a setLooped enabled audio file in my app, but every time the audio file loops, there is a noticeable, though very brief, gap in the audio playback... is there any way to get around this?
I was just facing the same problem and I guess you have been using MP3 or OGG files or some other compressed format. The solution is to use WAV files instead. This may increase your apk size but lets you loop gapless.
I had the same problem and did try to switch from MP3 to WAV. Then looping worked gaplessly in emulator, but not in my phone. Using OGG files actually made it work in phone too. So using .ogg could be worth a shot too, but I don't actually underst