-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Access WAVEFORMATEX? #1
Comments
I could get the sample rate via,
However, the bit depth is strange:
The bit depth should be multiples of 8. The device's bit depth was set as 24 bit. However, wBitsPerSample value was 5. |
you may want to cast the pointer that is returned by GetMixFormat so here would be an example. import ctypes
from pyWinCoreAudio.__core_audio.audioclient import WAVEFORMATEEX
waveformatex = ctypes.cast(audiodevice.render_endpoints[0].audio_client.GetMixFormat(), ctypes.POINTER(WAVEFORMATEEX))
# I do not remember off hand which way you are going to be able to access the information
waveformatex.contents.wBitsPerSample
# or this
waveformatex.wBitsPerSample You can give that a try. Now I have not messed with this library in some time. but if memory serves the returned waveformatex structure is going to be the audio stream data. I would have to double check that. The easiest way to be 100% sure is if you use Media Player to play an MP3 that you know the bitrate for (this can be found out by checking in the Windows Explorer (File Explorer) and look at the metadata for the MP3. and check to see if the returned value from GeetMixFormat is the same. I would have to check and see if Microsoft used some kind of funky math for the bitarte they may have. |
ok never mind. I just realized you are trying to get the bit depth not the bit rate. if is is not a lossless audio format you will get an incorrect value. during the encoding process alot of the time the bit depth data gets removed. see the link below. https://stackoverflow.com/questions/27652123/how-to-know-the-bit-depth-of-a-mp3-file also on Microsoft's API white papers it states
the keyword in that is stream. not device. |
Hello
I want to read the sample rate and bit depth for the current audio endpoint. It seems like the structure is called WAVEFORMATEX and it is in the library, but not utilized. How do I get this?
The text was updated successfully, but these errors were encountered: