How to get the raw pcm data when capture? #525
-
I want to process multi-channels raw pcm data(micphone array) when capture and write the processed data into file, but I don't know how to get and control(such as frame size ) the raw pcm data, thanks for your kind helping |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
You'll want to initialize a capture device. See the simple_capture example - that should cover almost everything you need. In the config, set the sample rate and channel count to 0 and the format to After the device has been initialized, you can inspect the following members of the ma_format format = device.capture.format;
ma_uint32 channels = device.capture.channels;
ma_uint32 sampleRate = device.sampleRate; The data callback will give you the raw data. You can use |
Beta Was this translation helpful? Give feedback.
-
but I dont know how to get this buffer,where should I copy data from?Can you please show me the code
发自网易邮箱大师
On 08/30/2022 06:09, David Reid wrote:
You can calculate the size of a buffer like this:
sizeInBytes = deviceConfig.periodSizeInFrames * ma_get_bytes_per_frame(device.capture.format, device.capture.channels);
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
[
{
***@***.***": "http://schema.org",
***@***.***": "EmailMessage",
"potentialAction": {
***@***.***": "ViewAction",
"target": "#525 (reply in thread)",
"url": "#525 (reply in thread)",
"name": "View Discussion"
},
"description": "View this Discussion on GitHub",
"publisher": {
***@***.***": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
|
Beta Was this translation helpful? Give feedback.
-
I mean where is the buffer pointer
发自网易邮箱大师
在2022年08月30日 08:45,Yangang Cao 写道:
but I dont know how to get this buffer,where should I copy data from?Can you please show me the code
发自网易邮箱大师
On 08/30/2022 06:09, David Reid wrote:
You can calculate the size of a buffer like this:
sizeInBytes = deviceConfig.periodSizeInFrames * ma_get_bytes_per_frame(device.capture.format, device.capture.channels);
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
[
{
***@***.***": "http://schema.org",
***@***.***": "EmailMessage",
"potentialAction": {
***@***.***": "ViewAction",
"target": "#525 (reply in thread)",
"url": "#525 (reply in thread)",
"name": "View Discussion"
},
"description": "View this Discussion on GitHub",
"publisher": {
***@***.***": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
|
Beta Was this translation helpful? Give feedback.
-
You read from the input buffer provided by the data callback, and you write to your own buffer. You need to allocate and manage the buffer yourself. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply, there is the other question:
I have read the raw data from input buffer provided by the data callback, but test.wav is needless, how can I prevent data from writing to test.wav? |
Beta Was this translation helpful? Give feedback.
-
thanks for your reply, I will try to read and modify the source code. |
Beta Was this translation helpful? Give feedback.
You read from the input buffer provided by the data callback, and you write to your own buffer. You need to allocate and manage the buffer yourself.