same mp3 files behave differently in iPhone app - audio

I have 2 mp3 files that are nearly identical. The first file refused to stream down and play in my Appcelerator iPhone app that I am developing:
http://www.zerogravpro.com/temp/bad.mp3 (you'll find you can play this just fine in your browser, or download it and it plays fine)
This is 100% replicatable; it's not sporadic at all. The actual behavior is that the file begins to play in the iphone mediaPlayer for just a split second, then stops with some kind of "unknown" error. So then I took that file, opened it in audacity, removed the first split-second of silence from the beginning of the clip, and re-generated the mp3:
http://www.zerogravpro.com/temp/good.mp3
And this one works perfectly in the iphone app! 100% success each and every time. I have many mp3 files that are similar to bad.mp3 in that they play fine in any audio device, but error out when streaming/playing in iphone's media player. Audacity fixed it somehow and I need to know how/why, so that I can automate the fix in my hundreds of other mp3 files. I'd love to not have to open hundreds of files in Audacity and re-save. There must be some way to automate these fixes. How did Audacity fix the file? What did it do? I can only think of 2 possibilities:
The existence of a split second of silence at the beginning of the clip chokes iphone
Audacity fixes something non-obvious in the mp3
Experts: Any idea what the difference is between these 2 files, and how I could automatically turn "bad" mp3s into good ones, from some command-line tool or something? Thanks all.

I discovered that the only difference between the files that actually matter is the size. iPhone apps (at least in the simulator), when using the audio streaming library, choke on any file under 40Kb. So you have to use the standard sound library for the smaller files.

Related

How to Playback Multiple Audio Files Starting at Different Times

I have two audio files of different durations. I want to play them simultaneously with the shorter duration starting in the middle of the longer duration file.
I've enabled media synchronization with the app launch setting --sout-all --sout #display.
Swapping between input-master and -slave settings results in either the shorter file not playing or nothing played back.
How can this be done in VLC?
As of the date of this response, asynchronized audio playback or recordings where files start and end at different times cannot be done using a single instance of VLC alone without customized addons, if available. This case is not an intended use of the VLC standard application.
It is possible yet cumbersome to have asynchronized playback with two or more instances of VLC and manually starting and ending each audio track.
ALTERNATIVES
Alternatively, there are numerous online audio editing tools, many accessible freely, that permit uploading audio files as separate tracks for playback, editing, mixing, or recording and for downloading that are much more advanced than the features of an uncustomized VLC.
A web search for "audio editors online" will produce a lengthy list of options.

Easiest way to play mp3 files in python to a specific device

I'm converting an ESP32 project to a Raspberry Pi zero. One of the project behaviors is to play back sound effects based on specific events or triggers. I prefer to use MP3 format so I can store information about the contents of the file in the ID3TAGs to make the files themselves easier to manage. (there are a lot of them!)
I can find examples of using any number of libraries to play mp3s in python, and I found an example of selecting a device using 'sounddevice' but it seems to want numpy arrays to play sound data.
I'm wondering what the easiest and quickest way is to play mp3 files (or should I go to some other file format with a data stub file for each to do my file management?).
Since these behaviors are played as responses, they need to at least start playback quickly (i.e. not wait for a format conversion to take place). And in some cases, other behaviors (such as voice recognition triggers) are already going to add to potential latency on the device in it's total response time.
EDIT: additional info
quickest means processor speed (pi zeros slow down quick under heavy load)
These are real time responses so any 'lag' converting defeats the purpose of the playback.
Also, the device from seeed is configured as an alsa (asound) device

Download and play partial audio files in Python

I have an audio streaming application that uses requests to download the audio file and then played using Gstreamer.
I want to trim the first few seconds of all the audio files that i have. I could use ffmpeg to trim but that would waste cpu resources on my embedded platform and also waste network bandwidth
(The number of songs are around 1000, and they get downloaded continously, so it does make a difference)
I have tried downloading partial file using the range header in requests but that doesn't work. I can't play the file.
Can someone please tell me how i can make this work?
The audio files are generally .m4a / .webm but they are extracted from youtube so can't say for sure.
This is an uneasy task.. there is no clean way how to do it..
you can probably use the valve element set it to drop by default..
and then put some timer which sets the drop to false..
not sure how this will work, you need to try.
Here are some hints:

What is the best practice of saving an audio file with louder volume?

I would like to save a quiet audio file with more volume. Can you suggest me a program, method to do it?
The device I would like to use the audio file on is not very intelligent and the maximum volume setting is too quiet for me. Other audio files (that are louder) can be played fine on the device. So I thought, I open the file on PC, modify it to be louder, save it, then the device will play this fine too. I am aware of distortions and such, that is not the point now.
I have used VLC player and I can make a setting where the audio file is loud enough with little distortions, but I can not find the options to save the file with these settings. It is an MP3 file.
Thanks for the help,
Sziro
Increasing the volume of an audio file so that the peaks are at (or near) the maximum level is called normalisation. You can use an audio editior like audacity or there are dedicated solutions. Normally if saving to mp3 you normalise to slightly less than full volume (say -0.5 dB).
You might also want to consider compressing the audio. This will be useful if the peaks in your audio are much louder than the quiet passages, and the quiet passages are hard to hear as a result. Again, you can do this in audacity.

Audio Playback control in C++

I'm working on a project that requires me to sync an audio playback(preferably an mp3 file) with my program.
My program reads a motion file from a txt file and output's it onto the serial port at a particular rate. At the same time an audio file has to be played back on the speaker. This audio file has to be in sync with the data..that is to say after say transmittin 100 bytes of data, the audio mustve played back to a predefined time.
What would be the tools used to play and control audio like this?
a tutorial would be great!
Thanks!!
In general, when working with audio, you want to synchronize other sources to audio. This is for several reasons, but most important is that audio runs on a clock running on its own hardware. You'll have to get timing information from that clock. There is a guide here written for using portaudio, but the principles apply to other situations:
http://www.portaudio.com/docs/portaudio_sync_acmc2003.pdf

Resources