How to change bitpersample of audio ?
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Rahul
il 6 Nov 2024 alle 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 Commenti
Vedere anche
Categorie
Scopri di più su Audio I/O and Waveform Generation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!