pyaudio bytes data to librosa floating point time series
when audio is recording using pyaudio with paInt16
, it gives me 16 bits integer represented as two bytes. With some studying, I concluded that it must be # between -32768 to 32767.
I saved audio as wav file and load it back with librosa.core.load
.
I did retrieved float value * 32767 and see whether it generates original 16bits integer but it was not matching at all.
My questions are
- Where is this mismatch coming from??
- is original 16-bit integer data represents frequency?
- librosa doc state that load function returns
floating point time series
. how do you calculate this value from the original 16-bit integer?
audio wav pyaudio librosa
add a comment |
when audio is recording using pyaudio with paInt16
, it gives me 16 bits integer represented as two bytes. With some studying, I concluded that it must be # between -32768 to 32767.
I saved audio as wav file and load it back with librosa.core.load
.
I did retrieved float value * 32767 and see whether it generates original 16bits integer but it was not matching at all.
My questions are
- Where is this mismatch coming from??
- is original 16-bit integer data represents frequency?
- librosa doc state that load function returns
floating point time series
. how do you calculate this value from the original 16-bit integer?
audio wav pyaudio librosa
How doc you compare the data? By default librosa resamples to 22050Hz, so if you are comparing raw values for the frames, they will not match at all.
– jonnor
Dec 5 '18 at 2:17
Scaling the int16 data by dividing by 32767 should make it be on the expected format of librosa. But pay attention to samplerate, pass in the value that pyaudio gives you
– jonnor
Dec 5 '18 at 2:19
add a comment |
when audio is recording using pyaudio with paInt16
, it gives me 16 bits integer represented as two bytes. With some studying, I concluded that it must be # between -32768 to 32767.
I saved audio as wav file and load it back with librosa.core.load
.
I did retrieved float value * 32767 and see whether it generates original 16bits integer but it was not matching at all.
My questions are
- Where is this mismatch coming from??
- is original 16-bit integer data represents frequency?
- librosa doc state that load function returns
floating point time series
. how do you calculate this value from the original 16-bit integer?
audio wav pyaudio librosa
when audio is recording using pyaudio with paInt16
, it gives me 16 bits integer represented as two bytes. With some studying, I concluded that it must be # between -32768 to 32767.
I saved audio as wav file and load it back with librosa.core.load
.
I did retrieved float value * 32767 and see whether it generates original 16bits integer but it was not matching at all.
My questions are
- Where is this mismatch coming from??
- is original 16-bit integer data represents frequency?
- librosa doc state that load function returns
floating point time series
. how do you calculate this value from the original 16-bit integer?
audio wav pyaudio librosa
audio wav pyaudio librosa
asked Nov 24 '18 at 20:24
Brandon LeeBrandon Lee
676
676
How doc you compare the data? By default librosa resamples to 22050Hz, so if you are comparing raw values for the frames, they will not match at all.
– jonnor
Dec 5 '18 at 2:17
Scaling the int16 data by dividing by 32767 should make it be on the expected format of librosa. But pay attention to samplerate, pass in the value that pyaudio gives you
– jonnor
Dec 5 '18 at 2:19
add a comment |
How doc you compare the data? By default librosa resamples to 22050Hz, so if you are comparing raw values for the frames, they will not match at all.
– jonnor
Dec 5 '18 at 2:17
Scaling the int16 data by dividing by 32767 should make it be on the expected format of librosa. But pay attention to samplerate, pass in the value that pyaudio gives you
– jonnor
Dec 5 '18 at 2:19
How doc you compare the data? By default librosa resamples to 22050Hz, so if you are comparing raw values for the frames, they will not match at all.
– jonnor
Dec 5 '18 at 2:17
How doc you compare the data? By default librosa resamples to 22050Hz, so if you are comparing raw values for the frames, they will not match at all.
– jonnor
Dec 5 '18 at 2:17
Scaling the int16 data by dividing by 32767 should make it be on the expected format of librosa. But pay attention to samplerate, pass in the value that pyaudio gives you
– jonnor
Dec 5 '18 at 2:19
Scaling the int16 data by dividing by 32767 should make it be on the expected format of librosa. But pay attention to samplerate, pass in the value that pyaudio gives you
– jonnor
Dec 5 '18 at 2:19
add a comment |
1 Answer
1
active
oldest
votes
After studying and exploring the librosa code, here are my findings.
The mismatch comes from the fact that wav byte array is little endian
The representation is called Pulse-code modulation(PCM). Each sample (single integer) represents the magnitude of audio scaled to the range of prespecified bit range, (usually 16 bits). refer audio bit depth for detail
Given PCM is 16 bits representation, each sample has a range of [-32768, 32767]. librosa simply transform 16 bits into signed short and divide by 32768 (not 32767!) to scale down to [-1, 1] range. please refer to my sample code for exact conversion
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462062%2fpyaudio-bytes-data-to-librosa-floating-point-time-series%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
After studying and exploring the librosa code, here are my findings.
The mismatch comes from the fact that wav byte array is little endian
The representation is called Pulse-code modulation(PCM). Each sample (single integer) represents the magnitude of audio scaled to the range of prespecified bit range, (usually 16 bits). refer audio bit depth for detail
Given PCM is 16 bits representation, each sample has a range of [-32768, 32767]. librosa simply transform 16 bits into signed short and divide by 32768 (not 32767!) to scale down to [-1, 1] range. please refer to my sample code for exact conversion
add a comment |
After studying and exploring the librosa code, here are my findings.
The mismatch comes from the fact that wav byte array is little endian
The representation is called Pulse-code modulation(PCM). Each sample (single integer) represents the magnitude of audio scaled to the range of prespecified bit range, (usually 16 bits). refer audio bit depth for detail
Given PCM is 16 bits representation, each sample has a range of [-32768, 32767]. librosa simply transform 16 bits into signed short and divide by 32768 (not 32767!) to scale down to [-1, 1] range. please refer to my sample code for exact conversion
add a comment |
After studying and exploring the librosa code, here are my findings.
The mismatch comes from the fact that wav byte array is little endian
The representation is called Pulse-code modulation(PCM). Each sample (single integer) represents the magnitude of audio scaled to the range of prespecified bit range, (usually 16 bits). refer audio bit depth for detail
Given PCM is 16 bits representation, each sample has a range of [-32768, 32767]. librosa simply transform 16 bits into signed short and divide by 32768 (not 32767!) to scale down to [-1, 1] range. please refer to my sample code for exact conversion
After studying and exploring the librosa code, here are my findings.
The mismatch comes from the fact that wav byte array is little endian
The representation is called Pulse-code modulation(PCM). Each sample (single integer) represents the magnitude of audio scaled to the range of prespecified bit range, (usually 16 bits). refer audio bit depth for detail
Given PCM is 16 bits representation, each sample has a range of [-32768, 32767]. librosa simply transform 16 bits into signed short and divide by 32768 (not 32767!) to scale down to [-1, 1] range. please refer to my sample code for exact conversion
answered Dec 6 '18 at 17:13
Brandon LeeBrandon Lee
676
676
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462062%2fpyaudio-bytes-data-to-librosa-floating-point-time-series%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How doc you compare the data? By default librosa resamples to 22050Hz, so if you are comparing raw values for the frames, they will not match at all.
– jonnor
Dec 5 '18 at 2:17
Scaling the int16 data by dividing by 32767 should make it be on the expected format of librosa. But pay attention to samplerate, pass in the value that pyaudio gives you
– jonnor
Dec 5 '18 at 2:19