How to Playback Multiple Audio Files Starting at Different Times - audio

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.

Related

Cannot play video stream in two instances of VLC player

We are using libvlc in our Linux application to play an RTP MJPEG stream from an IP camera. We'd like to have two libvlc_media_players playing the video, one playing a full image in a GtkDrawingArea, and another playing a cropped/resized portion of the video (pseudo-zoom) in another GtkDrawingArea.
The problem is, only one of the media players is working. It seems whichever instance connects first, is blocking the second instance from binding to the port.
We need a way replicate the traffic to two ports may be or any other advice?
You have at least 2 ways to achieve what you want, depending on the exact result you need.
While you can only call libvlc_new once, and so have only 1 libvlc instance in your app running at all times, you may create as many media players as you want from libvlc. They will be independant though, so if you need exact sync, this isn't what you want to use.
One other way would be to duplicate the video output, using for example
Clone video filter (clone)
Duplicate your video to multiple windows and/or video output modules
--clone-count=<integer> Number of clones
Number of video windows in which to clone the video.
--clone-vout-list=<string> Video output modules
You can use specific video output modules for the clones. Use a
comma-separated list of modules.
https://wiki.videolan.org/VLC_command-line_help
with libvlc_media_add_option (replace -- with : when using this function).
You can also use --sout with #duplicate as well. https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/
Depending on the way you choose, VLC might create a new Window by itself, which you might have to grab and incorporate in your app.

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

same mp3 files behave differently in iPhone app

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.

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

Audio stream mangement in Linux

I have a very complicated audio setup for a project. Here's what we have:
3 applications playing sound
2 applications recording sound
2 sound cards
I really don't really have the code to any of these applications. All I want to do is monitor and control the audio streams. Here are a few examples of operations I'd like to do while the applications are running:
Mute one of the incoming audio streams.
Have one of the incoming audio streams do a "solo" (be the only stream that can "talk").
Get a graph (about 30 seconds worth) of the audio that each stream produced.
Send one of the audio streams to soundcard #1, but all three audio streams to soundcard #2.
I would likely switch audio streams every 2 minutes or so with one of the operations listed above. A GUI would be preferred. I started looking at the sound systems in Linux and it gets extremely complex and I feel like there have been many new advances in the past few years. I see jack, pulseaudio, artsd, and several other packages. They all have some promise but where should I start? Is there something someone already built that can help?
PulseAudio should be able to let you do all that. You'll need to configure a custom pipeline for splitting the app's audio for task 4, and I'm not exactly certain how you'd accomplish task 3, but I do know that it's capable of all sorts of audio stream handling via its volume control (pavucontrol).
I use Jack, which is quite simple to install and use, even if it
requires more efforts to configure with Flash and Firefox ...
You can try the latest Ubuntu Studio distribution and see if it solves your
problem (for the GUI, look at "patchage").

Resources