audio,wasapi , Upgrading audio code to new WASAPI standard
Upgrading audio code to new WASAPI standard
Question:
Tag: audio,wasapi
We have an application that uses waveXXX()
and mixerXXX()
functions to handle the audio I/O to and from some instruments (think: oscilloscope or electronics rather than musical instruments, not that it much matters). It's finally time to stop deploying it on Windows XP, and move it to Windows 7 and/or 8.
From reading a variety of material on WASAPI, it sounds like the bulk of the application (based on waveXXX()
functions) might actually work fine, but the mixer()
stuff used to set master output volume, line in volume, and mute the microphone will definitely have to change, and use IAudioEndPointVolume calls instead.
Is it possible to change only the mixerXXX()
calls? Is it desirable?
Logically, this application requires exclusive use of its audio endpoints (speaker out, line in). If I want to ensure exclusive access through software, would that force me to rewrite all the waveXXX()
code too? (The alternative is to warn users that other audio applications may interfere with this one).
Answer:
My recommendation:
- If you need exclusive access, convert everything to WASAPI
- If you are using line-in, convert everything to WASAPI
- If you have time, convert everything to WASAPI
- If you are strictly only using speaker and microphone in shared mode, replace
mixerXXX()
with the ISimpleAudioVolume
interface (and several other interfaces to get to it), then test whether existing waveXXX()
code behaves as you need it to. Then test each time hardware, OS or audio drivers change. Better still, just convert to WASAPI.
In my case, exclusive speaker output is critical - this drives the instrument that generates a related input signal. I guess I don't mind if another application wants to share access to that incoming signal, but logically it is a system that wants an exclusive contract with its audio endpoints.
That exclusivity requires that I obtain an IMMDevice
instance for both speaker output and line-in input, Activate()
the IAudioClient
interface on them and Initialize()
both using AUDCLNT_SHAREMODE_EXCLUSIVE
(see also this answer).
But have I actually selected line-in by such a process? Probably not. All I can be sure of is annoying any other applications who were previously sharing my endpoints by cutting them off.
Having done this much, it's really not clear what will happen to waveInXXX()
calls - maybe they'll take from line-in, maybe from microphone - maybe it depends on how the hardware vendor implements their end of the deal. It's also never been clear to me whether line-in and microphone are always multiplexed (i.e. selectable), always mixed (i.e. you can only simulate selection by muting the other one) or there is no standard one can rely on.
Because of factors like that, it's a gamble not to use WASAPI throughout.
Related:
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...
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...
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...
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...
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,...
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...
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 =...
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()...
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...
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();...
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...
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...
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...
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...
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();...
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...
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...
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:...
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...
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");...
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...
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...
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...
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"...
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>...
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....
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?...
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...
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...
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...
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...
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...
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...
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>...
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,...
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...
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>...
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...
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...
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);...
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...
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...
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...
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;...
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...
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...
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...
.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...
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...
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...