Using setTempo and putSamples in SoundTouch - soundtouch

Which samples does SoundTouch::setTempo affect, those already in the FIFO or those that are going to be put into the FIFO by SoundTouch::putSamples? That is, does SoundTouch::setTempo commit or prepare a tempo change?

Related

Custom player using NDK/C++/MediaCodec - starvation/buffering in decoder

I have a very interesting problem.
I am running custom movie player based on NDK/C++/CMake toolchain that opens streaming URL (mp4, H.264 & stereo audio). In order to restart from given position, player opens stream, buffers frames to some length and then seeks to new position and start decoding and playing. This works fine all the times except if we power-cycle the device and follow the same steps.
This was reproduced on few version of the software (plugin build against android-22..26) and hardware (LG G6, G5 and LeEco). This issue does not happen if you keep app open for 10 mins.
I am looking for possible areas of concern. I have played with decode logic (it is based on the approach described as synchronous processing using buffers).
Edit - More Information (4/23)
I modified player to pick a stream and then played only video instead of video+audio. This resulted in constant starvation resulting in buffering. This appears to have changed across android version (no fix data here). I do believe that I am running into decoder starvation. Previously, I had set timeouts of 0 for both AMediaCodec_dequeueInputBuffer and AMediaCodec_dequeueOutputBuffer, which I changed on input side to 1000 and 10000 but does not make much difference.
My player is based on NDK/C++ interface to MediaCodec, CMake build passes -DANDROID_ABI="armeabi-v7a with NEON" and -DANDROID_NATIVE_API_LEVEL="android-22" \ and C++_static.
Anyone can share what timeouts they have used and found success with it or anything that would help avoid starvation or resulting buffering?
This is solved for now. Starvation was not caused from decoding perspective but images were consumed in faster pace as clock value returned were not in sync. I was using clock_gettime method with CLOCK_MONOTONIC clock id, which is recommended way but it was always faster for first 5-10 mins of restarting device. This device only had Wi-Fi connection. Changing clock id to CLOCK_REALTIME ensures correct presentation of images and no starvation.

How to change the bitrate of audio encoding in Gstreamer in the PLAYING state?

I want to convert a FLAC file to a MP3 (and Vorbis, in a second time) file.
These MP3/Vorbis streams are then transmitted, raw, to a second device that decodes them.
Depending on the quality of the transmission, I want to be able to change the bitrate on-the-fly.
The change must be gapless (hence the "in the PLAYING state" in the title).
The specific encoders are lamemp3enc and vorbisenc (and cannot be changed).
To my knowledge, changing the bitrate while playing is actually not possible with these codecs.
But I guess there are clean and simple ways to change the bitrate without introducing any gap in the stream: I'd like to learn about any of them.
(NB: I did write any, not all, I am not asking for the "best" way, I am not asking for a review, I just want something that works.)
Read through this ..
You will:
block element before lamemp3enc
flush the encoded frames into queue with EOS sent to lame and discard the EOS when it comes out of lame
then set the lamemp3enc into NULL state
change the parameters
set lame to PLAYING or PAUSED - this will preroll it again with new data using new bitrate
check when lame is in playing and then you know everything is working
there should be no gap as queue has lot of old buffers which it sends forward during you are doing the witch
You can inspire yourself with the example from the link above.. However you are not doing any removing and adding new elements.. Do not forget to set it to NULL state as it will discard all internal states (well hopefully if its not buggy). Then You would just change the parameters with g_object_set...
Also I never did this so you may also ask on IRC of #gstreamer at freenode if you are stuck or not sure.
HTH

NI Reaktor Audio Input Vertical Line

I recently restartet patching in Reaktor and found something strange. In one of my Primary structures there is an input pin switching its icon to vertical line every now and then when I edit the structure. It somehow depends on the audio processing sequence.
Unfortunately I cannot post an image of the structure, because this needs more reputation... however, does anyone know what is the point with this port? It feels spooky. Thanks!
sounds to me like a audio loop indicator.
It appears if the signal flow is feed back so that it can't processed at the same time. In this case the feedback signal gets feed in one audio clock later.
What means that this port has a delay of 1 sample.
In order to determine yourself where this delay applies you may insert the Unit Delay what does the same job (1 sample delay) but at the place you want.

Is it possible to play a gapless looped WAV file without stuttering?

I have a requirement for perfect gapless looped audio in a BlackBerry 10 app. My loops are stored as WAV files. The method I'm using for playing them is:
Create a buffer for the WAV file using alutCreateBufferFromFile which returns a bufferID
Create a sound source using alGenSources
Attach the buffer to the source using alSourcei(source, AL_BUFFER, bufferID)
Set the source looping property to true using alSourcei(source, AL_LOOPING, AL_TRUE)
Play the source using alSourcePlay(source)
The audio plays fine most of the time, but during UI transitions (such as when the backlight goes off, or when the app is minimised) the audio stutters.
Any ideas how I can ensure the audio is smooth the whole time?
How do you run a thread/process playing WAV file? Have you had a chance to play around priorities and policies with that thread?
I think these low-level system calls allowing to change process (thread, actually) priority and policy might help:
pthread_setschedprio
pthread_setschedparam
Also, have a look at respective doc pages:
BB10 Priorities
BB10 Scheduling policies
QNX Neutrino MicroKernel
I'd start with setting policy to FIFO and raise priority of the process playing audio file. Hope it helps.

How to play a song with Audio Queue API in order to find the Accurate timings of the beat of the song

Now I am working on a musical project in which i need accurate timings.I already used NSTimer,NSdate,but iam geting delay while playing the beats(beats i.e tik tok)So i have decided to use Audio Queue API to play my sound file present in the main bundle that is of .wav format, Its been 2 weeks i am struggling with this, Can anybody please help me out of this problem.
Use uncompressed sounds and a single Audio Queue, continuously running. Don't stop it between beats. Instead mix in raw PCM samples of each Tock sound (etc.) starting some exact number of samples apart. Play silence (zeros) in between. That will produce sub-millisecond accurate timing.

Resources