How do I programatically query the audio card in a Mac/PC to find sample rate, bit depth and other audio card parameters?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to derive the audio sample rate and bit depth (maybe number of channels) of my audio card (or specified "device") is set to within a script. Is there a way to query these value? I want the script to be able to process the audio in "sync" with the audio stream coming from my specified device. Currently I have to know the parameters an modify my scripts accordingly.
1 comentario
Walter Roberson
el 2 de Mzo. de 2023
I have been digging into some specifications for some sound chips, trying to find the actual supported hardware rates.... the most I have been able to come up with is hints that the output of some sound chips depends on the clock rate, with a range of clock rates being supported.
The question is starting to feel like one of those questions asking "exactly" what rate an I/O device can run when it turns out that the rate can be integer multiples of basic frequency divided by a register. Along the lines of "Well it is true that this rs232 port cannot handle exactly 81957 baud, but by using the appropriate combinations of multipliers and dividers it can handle 81956.994125 or 81957.0063875 baud" and you saying "See! I told you it had important limitations! I should have been able to query to find out exactly what it supports!".
Respuestas (1)
Walter Roberson
el 4 de Mzo. de 2023
I tried digging further into Apple's audio interface to see if I could find device descriptors of supported audio rates.
The descriptors that are made available for listing devices... have no information about rates, and there is nothing I can find in the relevant classes that would permit using a device descriptor to find the supported rates.
I also see https://rogueamoeba.com/support/knowledgebase/?showArticle=Loopback-Aggregate-Device-Drift-Correction which talks about aggregate devices, which might possibly be for a newer MacOS release than I have installed. The drift correction permits tying a group of devices to the clock rate of a selected device so that the devices do not lose synchronization. The documentation there explicitly says that two hardware devices with the same nominal rate are not going to stay synchronized without a common clock. Note that the solution is not given as tying them to some shared master system clock: the solution is given as tying them to any chosen device even as it drifts . This implies that the tuning is not "digital", but rather hardware waveform level. And that makes the current hardware output rate unknowable (unless there is some kind of feedback measurement that I missed.)
5 comentarios
Walter Roberson
el 5 de Mzo. de 2023
The older MacOS interface appears to be described at https://audiokitpro.com/auv3-midi-tutorial-part2/ in terms of AudioUnit instead of newer AUAudioUnit
You have to go fairly fair down in the Apple Heirarchy to deal with actual device rate capacilities. Apple designed in terms of any number of user-selectable conversion steps (including rate conversions) until finally you hit the Hardware Abstraction Layer and the last step in that layer is for outputs to do rate conversions .
The channels do not involve sending just streams of samples that are to be blindly converted according to the then-current output rate: the channels involve sending blocks of signals that have timing information accompanying them in the channels, and then at the last minute the hardware abstraction converts for the actual hardware capability. The actual hardware capability is designed to be mostly opaque.
2022-ish Mac devices added a higher speed output device that is configured through midi controls; https://support.apple.com/en-ca/HT212854
Ver también
Categorías
Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!