audio,wasapi , Audio latency versus reliability


Audio latency versus reliability

Question:

Tag: audio,wasapi

Is there any tradeoff between latency and reliability in an audio stream on Windows using WASAPI?

That is, if I'm programming a WASAPI application and I want the minimum latency, will the audio stream be subject to more pops and clicks and audio disturbances than if I use a higher latency? Is using the lowest latency possible a "free lunch", or something that comes with caveats?


Answer:

Latency is a function of the buffer size (e.g. bufferSize/sampleRate). By increasing the buffer size you reduce the chance that say a D/A converter is going to consume the current buffer of samples before the OS has given your application a chance to fill the next buffer. The downside is that the latency is increased. The effect of the increased latency is that changes you make during playback (e.g. increasing the volume) won't be heard until the next buffer is played. At the extreme you could imagine a 1 sample buffer between your application and the sound card. You'd have zero latency but there is no way the Windows scheduler would service you regularly enough to prevent drop outs.

There is no such thing as a free lunch but as computers have continued to speed up the chances of buffer underruns have decreased quite a bit.


Related:


Callback for connected/unconnected device using portaudio?


c++,audio,portaudio
Is there a callback to know when the device list is updated? If not, is there a way of detecting it ( ideally cross platform )? At the moment the only way i found is to re-initialise PortAudio. ps: I tried to find "callbacks" documentation on PortAudio documentation but i...

mediaelement.js - How to change width


javascript,audio,media-player,mediaelement.js,mediaelement
I have tried to find which of the plethora of tags controls the width of the mediaelement.js audio player but can't seem to work it out. I'm assuming it's a combination of the tags that need to be edited? I downloaded the player from the mediaelemenjs.com and the CSS for...

ios - How to play MPMediaItemCollection?


ios,iphone,swift,audio,mpmusicplayercontroller
So, I already stored few mpmediaitemcollection in NSUserDefaults. I already retrieve it on UICollectionView. here is my code: func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { self.performSegueWithIdentifier("toList", sender: self) User.mdci = decodedPlaylistData[indexPath.row] as? MPMediaItemCollection getSongListInfo((decodedPlaylistData[indexPath.row] as? MPMediaItemCollection)!) MPMusicPlayerController().setQueueWithItemCollection((decodedPlaylistData[indexPath.row] as?...

Unity 5 Audio Volume Slider (Solved)


c#,audio,unity3d
I am trying to create an slider that I can use for volume control in Unity 5 but the volume will not change. My Game Objects are called MainMusicPlayer for the audio source and Volume Slider for the slider I am going to post the whole script as it would...

AVAudioPlayer not playing long sounds?


ios,audio,avaudioplayer
I have a series of sound files ranging from 0.3s to 3.0s. When trying to play with AVAudioPlayer, I get nothing, unless I add a sleep(4) call after to ensure the sound can play. Really weird. Apart from that, no errors with the error param that gets passed in, and...

ios media picker shows only white screen/stuck


ios,iphone,swift,audio,mpmediapickercontroller
So I'm currently making an music application for my project, and it allows user to create their own music playlist. However when I clicked on show media picker button it only shows white screen, It doesn't happen when the view that contains media picker is Initial View Controller. But when...

My sounds are not playing in Chrome


javascript,html5,google-chrome,audio
I have a small, very basic 3d game that runs in all browsers. But my issue is that when it runs in Chrome I can see in my console messages that the sounds are "pending" and don't play when they should. The thing is that after some time have passed...

Android How To Find Decibels


android,audio,microphone,decibel
I'm trying to get the decibels from the microphone and have looked everywhere how to correctly do it but they don't seem to work. I get the amplitude like this public class SoundMeter { static final private double EMA_FILTER = 0.6; private MediaRecorder mRecorder = null; private double mEMA =...

How do I calculate logrithmic labels for a VU meter scale?


javascript,html5,audio,canvas,html5-canvas
I writing a meter widget using canvas and need to calculate the label values for the scale. No problem except when I'm trying to re-create the scale for a VU meter. I understand it's logrithmic, but the values aren't powers of 10 on that type of meter. The function I...

Audio Jump Forward Button


swift,audio
I've got the following code tied to a 'Jump Forward' button: @IBAction func jumpForwardPressed(sender: AnyObject) { var currentTime = audioPlayer.currentTime var playForwardSkip = NSTimeInterval() audioPlayer.stop() audioPlayer.prepareToPlay() playForwardSkip = 3.0 // skip forward 3 seconds var skipF = currentTime + playForwardSkip println("currentTime:\(currentTime) and playForwardSkip:\(playForwardSkip) and skipF:\(skipF)") audioPlayer.playAtTime(skipF) When button is pressed,...

Playing a .wav file in c# using SoundPlayer


c#,audio,soundplayer
I am currently having a probelm, where a file was sent to me as .m4a and I renamed it to .wav..... (I think that is the issue as I can play other .wav files) Now it is giving me this error when I run the code: Additional information: The file...

Unity3d AudioSource not creatable


c#,audio,unity3d
I have a strange problem in unity3d. I want to use several audio sources for playing a sound with a overlapping effect. Because I can't explain the problem myself- I tried the same with only one AudioSource. So I have this script: public class audioOverlap:MonoBehaviour { private AudioSource sct; public...

Searching an arrayList generated by an audio recognition


java,android,audio,arraylist
I am working on app that take the audio of the user and save them in an arrayList, then searching this array list to see if the desired word generated by the google audio API exists, so we can do actions. The action that I wanted is removed and replace...

What's the reason of using Circular Buffer in iOS Audio Calling APP?


ios,objective-c,audio,core-audio,audiounit
My question is pretty much self explanatory. Sorry if it seems too dumb. I am writing a iOS VoIP dialer and have checked some open-source code(iOS audio calling app). And almost all of those use Circular Buffer for storing recorded and received PCM audio data. SO i am wondering why...

How to retrieve data from NSUserDefaults?


ios,swift,audio,nsuserdefaults,mpmediaitemcollection
currently, I try make an music playlist application. I try to save and retrieve playlist data from NSUserDefaults. I have no problem when saving the data but I got an error when retrieving data. I got: Terminating app due to uncaught exception 'MPMediaItemCollectionInitException', reason: '-init is not supported, use -initWithItems:...

How can I get my iPhone to listen for sound frequencies above a certain threshold?


ios,objective-c,iphone,audio
I'm interested in getting my iOS app to turn on the microphone and only listen for frequencies above 17000 hz. If it hears something in that range, I'd like the app to call a method. I was able to find a repository that detects frequency: https://github.com/krafter/DetectingAudioFrequency And here is a...

How to convert base64 string into an audio mp3 file?


php,audio,base64,mp3
I'm getting a base64 string from android side. I have to convert it into an audio file and have to save it into a folder. I thought I have to convert it first into byte array. Then after it, I have to convert it into a mp3 file. But don't...

Audio through built-in speakers when earphones are plugged in headphone jack in Android


android,audio,soundpool,android-audiomanager,headphones
In my application, there is one Card Reader which uses Audio Jack of devices.Now, my problem is I want to produce sound from built-in speakers when Card Reader is intact in HeadPhone Jack of the device. Here are the codes I have tried: 1) Using Reflection Methods Class audioSystemClass; try...

Javascript play multiple audio in loop


javascript,audio,while-loop
I create html and javascript for play sound number : <audio id="audio_0" src="0.wav" ></audio> <audio id="audio_1" src="1.wav" ></audio> <audio id="audio_2" src="2.wav" ></audio> <audio id="audio_3" src="3.wav" ></audio> <audio id="audio_4" src="4.wav" ></audio> <audio id="audio_5" src="5.wav" ></audio> <audio id="audio_6" src="6.wav" ></audio> <audio id="audio_7" src="7.wav" ></audio> <audio id="audio_8" src="8.wav" ></audio>...

Custom audio player issues


javascript,css,html5,audio
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/CSS"> #custom{ font-family: monospace; font-size: 16px; max-width: 650px; border-style: solid; border-color: black; border-width: 1px; border-radius: 5px; padding: 8px; padding-bottom: 15px; padding-left: 12px; padding-right: 12px; } img{ margin-top: 3px; float: left; } #bar, #currentTime, #duration, #skip{ display: inline-block; } #currentTime, #duration, #skip{ margin: 0px;...

VoIP limiting the number of frames in rendercallback


ios,objective-c,audio,core-audio,audiounit
I am currently developing a VoIP application and one of the libraries I am using requires me to send the frames in the input call back. The requirements is that I must send a sample count which is defined as the number of samples in a frame. This callback will...

Tried multiple solutions onsite, none worked: Play


javascript,jquery,html5,audio,interactive
This is my first question on Stack Overflow! :D There appear to be multiple similar questions, but I have tried each solution and none of them are working, and yet I'm determined to get to the bottom of this. The goal is to play audio upon successful konami code entry....

play audio periodically from a memory stream c#


c#,audio,windows-phone-8.1,memorystream
I have some buffer containing samples of sinus which I want to be played from a memory stream periodically. Is there any efficient way to play it without having gaps in time? I try to make my own signal generator (I know that are some libraries providing that but I...

Audio not working in Javascript


javascript,html,audio
I'm trying to get audio to play in general, but it does not seem to be working. I thought perhaps the interval or if statements were stopping it from playing, but as you can see even a call before all that does not make any sound. The directory is in...

WASAPI Loopback: Save wave file


c++,wav,file-format,wasapi,audioformat
I want to record the system's audio output using WASAPI and then saving it to a .wav file. So far I've followed these guides on WASAPI: https://msdn.microsoft.com/en-us/library/windows/desktop/dd316551%28v=vs.85%29.aspx https://msdn.microsoft.com/en-us/library/windows/desktop/dd370800%28v=vs.85%29.aspx I get the buffer data using audioCaptureClient->GetBuffer(&data, &numFramesAvailable, &flags, NULL, NULL); then, I'm processing this data, by just writing it at the...

Web Audio- streaming file from server to client


javascript,audio,types,web-audio
I'm trying to stream audio from a server containing an audio file to a client using BinaryJS. My code was inspired by the code in this question: Playing PCM stream from Web Audio API on Node.js Here's what my server code looks like: // create a BinaryServer using BinaryJS var...

RawSourceWaveStream volume control and playback time estimation with Naudio


audio,volume,naudio
I'm using Naudio to play audio samples from memory. private RawSourceWaveStream waveStream; private MemoryStream ms; private int sampleRate = 48000; private IWavePlayer wavePlayer; //generate sine wave signal short[] buffer = new short[(int)Math.Round(sampleRate * 10.00)]; double amplitude = 0.25 * short.MaxValue; double frequency = 1000; for (int n = 0; n...

How do I implement audio controls on this audio visualizer that uses HTML5 Web Audio API?


javascript,php,html5,audio,web-audio
I know how put audio controls when you're importing the source of the audio like so: <audio src="audio.mp3" id="audio" controls="true"></audio> What's different about the audio visualizer that im trying to fiddle with is that it uses the audio, that the user has to upload (test the demo below). What I...

Implementing VOIP over udp, what is the approach to take when the player cannot cope up with received packet's speed


android,audio,udp,voip,rtp
I am implementing p2p voice over IP on android, using UDP, openSL and some audio compression. The voice chat works good when 2 peers are connected, and the lag is steadily about 100ms. When a third peer connects, one or more peer progressively accumulate lag, reaching 15+ seconds in some...

Javascript alert box blocks sound object


javascript,audio,alert
I have a small problem. Basically, I am trying to make an application that it will pop up a box while playing a certain sound. Here is the fault part of the code: var audio = new Audio('song.mp3'); audio.play(); alert(1); The problem is that the audio plays after the alert...

Windows - sound recording program giving noise


windows,audio,wav
I wrote the following program to record the sound through soundcard in windows and print the PCM data from buffer of waveheader. But it gives only the data 32600-32700. Is the problem with my soundcard? I have used WAVE_MAPPER which automatically selects the source...Please help me #include <Windows.h> #include <MMSystem.h>...

iOS Swift: Sound not playing on iPhone Simulator


ios,iphone,swift,audio,ios-simulator
In my iOS Swift application, and i am trying to play sound on click of a button. func playSound() { var audioPlayer = AVAudioPlayer() let soundURL = NSBundle.mainBundle().URLForResource("doorbell", withExtension: "mp3") audioPlayer = AVAudioPlayer(contentsOfURL: soundURL, error: nil) audioPlayer.play() } I am running the application in iOS iPhone Simulator. I have doorbell.mp3...

AVAudioPlayer wont play sound when called in other swift file


ios,swift,audio,avaudioplayer
I have two swift files - my ViewController:UIViewController and AudioPlayer:AVAudioPlayer. My AudioPlayer file has this function func seaGullSound() { var tmp = AVAudioPlayer() var seaGullSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("Gulls", ofType: "mp3")!) AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: nil) AVAudioSession.sharedInstance().setActive(true, error: nil) var error:NSError? tmp = AVAudioPlayer(contentsOfURL: seaGullSound, error: &error) tmp.prepareToPlay()...

Unity3D Play sound from particle


audio,unity3d,collision,particles
I am trying to play a sound when a particle collides with a wall. Right now, it just plays the sound from the parent object, which is the player. However, I want the sound to play from the particle. Which means when a particle is far to the left, you...

How to force all sounds to shut down


java,android,audio
I'm making an application that makes a sound when a particulate thing happens, I made an other Layout that contains a button to stop that sound but the problem is that whenever I say MediaPlayer.stop();the application on the emulator or even on my mobile says the application has stopped The...

How do i play a sound in python 3?


python,audio,pygame
I wanted to write a python script to play a sound (recorded using windows recorder)! I read pygame can do the job and installed pygame! But I don't know how to write a code that plays a sound from a specific path! I have to play an audio file located...

With NAudio howto capture an signal played


.net,audio,naudio
Is there any way to capture a sound signal being played (by another application) in .NET (with or without the NAudio library)? What I want to do is build an graphical visualization of the sounds played (like there are plenty apps), but without playing the sound itself (which seems non...

How do I Mute The Audio In Unity 3D?


c#,audio,unity3d,mute
with script this. what is wrong in script this ? audio.mute = ToggleButton.isSpeakerOff; sorry bad english,fast answer please correct my script please...

Playing audio for given amount of time in Android


java,android,audio,media-player
I am new to Android development. In this application, I wanted an audio to play for certain duration (say 20 seconds). After 20sec it should not start to play. I used getDuration() method, but i didn't get what i need to. Code: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setVolumeControlStream(AudioManager.STREAM_MUSIC);...

Use toggle button to control sound


android,audio,togglebutton
I need my app to play all the sounds when toggle button is checked and stop playing them when it is unchecked.By all sounds I mean the sound played when other buttons present in the activity and other activities are pressed. Following is my toggle button: <ToggleButton android:layout_width="70dp" android:layout_height="70dp" android:id="@+id/toggleButton"...

onended audio event firing without playing the audio


javascript,html5,audio,javascript-events
I have multiple audio files that i need to be played. and only when all audio has been played completely the next section is supposed to show. the code that i've written fires automatically without playing any audio. how should i do it? here's my code <!DOCTYPE html> <html> <body>...

Stream.CopyTo(newStream) return Length 0


audio,windows-phone-8.1,memorystream
I try to make some concatenation of buffers which are saved in a memory streams. Then, when I'm trying to play the whole buffer it gives an exception: An exception of type 'System.ArgumentException' occurred in Microsoft.Xna.Framework.ni.dll but was not handled in user code Additional information: Ensure that the buffer length...

Get 403 (Forbidden) for audio tag


javascript,ajax,audio,html5-audio
I am using following JavaScript code for play audio after complete ajax: $(document).ready(function () { $.ajaxSetup( { cache: false, complete: function () { $('#loading').hide(); $('#page_content').show(); //get gold price and compire timestamp var published_date = $("#goldprice").data("published"); var currend_date = Math.floor(Date.now() / 1000); var compare_date = currend_date-published_date; if( compare_date <= 10){ document.getElementById('ding').play();...

video to audio file convert & save through FFMPEG in node js


javascript,node.js,audio,video,ffmpeg
I am working on an FFMPEG on node js. I'd like to retrieve the audio track from a video file using node js. I would also like to save such file but I can't figure out how. I though this line of code would help me : ffmpeg('/path/to/file.avi').noVideo(); I have...

fftw of 16bit Audio :: peak appearing wrong at 2f


c++,audio,fft,fftw,portaudio
I am taking 32bit float audio(44.1Khz) on my PC(between -1 and +1) using Port Audio and taking fft of it with fftw. Now I need to take the 16bit int Audio and take its fft. I have converted the Audio samples to float between -1 and +1. The fft works...

How do I swap stereo channels in raw PCM audio data on OS X?


audio,aiff
I'm writing audio from an external decoding library on OS X to an AIFF file, and I am able to swap the endianness of the data with OSSwapInt32(). The resulting AIFF file (16-bit PCM stereo) does play, but the left and right channels are swapped. Would there be any way...

“Converting” in jQuery an audio player with multiple tracks


javascript,jquery,audio
I have a tracklist and I'd like to serve a preview of 3 songs with just a play and pause button. Here's the messy snippet I have right now in JS: var playing = false; playpause01.addEventListener('click', function () { if (!playing) { document.getElementById('player01').play(); this.src = 'files/img/pause.png'; } else { document.getElementById('player01').pause();...

Audio on scroll


javascript,jquery,css,audio,skrollr
I'm doing a website with the skrollr plugin and I'm almost done with the pictures and scrolling itself, so I'm trying to add the audio now, but I can't seem to make the audio start and stop when I want it to. This is the script I am currently working...

Instantiating a SoundFile object within a class in Processing


audio,processing
I am attempting to create an instance of the SoundFile type inside of another class in Processing (the latest version, 3.0a10). I can easily play a sound that is defined outside of a class, as follows: import processing.sound.*; SoundFile clickSound; void setup() { size(600, 600); clickSound = new SoundFile(this, "bike-passing-by.wav");...

Invalid 'n' argument error in readBin() when trying to load a large (4GB+ audio file)


r,audio,runtime-error,analysis,tuner
I'm trying to load a sample from a 4GB+ mono WAV file (total file duration 24h, I'm loading a 15min slice). library(tuneR) so <- readWave( "file.wav", from = 1, to = 15, units = "minutes" ) This is the traceback Error in readBin(con, int, n = N, size = bytes,...