How to change bitpersample of audio ?
조회 수: 10 (최근 30일)
이전 댓글 표시
Hi everyone
Is it possible to change the audio bitpersample outside the range of 16 (default) | 8 | 24 | 32 | 64 with flac or wav codec format?
If possible how to do it?
For example : within the range 10, 12, 14, etc
댓글 수: 0
답변 (1개)
Rahul
2024년 11월 6일 6:35
Hi Sisi,
In order to sample your audio with non-standard bit ranges like 10, 12, 14 you can consider to quantize the audio data to the desired bit depth. Here is a sample code:
% Considering 'audioData' and 'sampleRate' as the variables with signal data and it's sampling rate
desiredBits = 12; % Can be adjusted
% Calculating 'quantizedAudio' by 'maxIntValue' according to the 'desiredBits'
maxIntValue = 2^(desiredBits - 1) - 1;
quantizedAudio = round(audioData * maxIntValue) / maxIntValue;
% Writing the 'quantizedaudio' as a .wav file
audiowrite('output.wav', quantizedAudio, sampleRate);
You can also refer to this MATLAB Answer, which mentions the use of 'quantiz' and 'discretize' functions:
Hope this helps! Thanks.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!