顯示具有 multimedia 標籤的文章。 顯示所有文章
顯示具有 multimedia 標籤的文章。 顯示所有文章

2018/01/04

Matlab: play a sound file with command

To play a sound file with Matlab commands, type:

>> [y, fs] = audioread('filename.wav');
>> sound(y, fs)
>> plot([1:size(y)]/fs,y); %Plot waveform

>> xlabel('sec');

2018/01/02

Matlab: record and play sound

To record sound with matlab, use audiorecorder() and getaudiodata()

In this example,
sample rate Fs = 8000
number of bits NBITS = 8
number of channels NCHANS = 1 = Mono

>> recorder = audiorecorder(8000,8,1);
>> record(recorder); //Say something
>> stop(recorder);
>> play(recorder);
>> data = getaudiodata(recorder, 'double');
>> sound(data, 8000);
>> plot([1:size(data)]/8000,data); %Plot waveform
>> xlabel('sec');

Waveform of Mandarin Chinese '1 2 3' (中文「一、二、三」的波形)

Reference:

McLoughlin, I. (2009). Applied speech and audio processing: with Matlab examples. Cambridge University Press. pp 7-10.

2017/03/12

PCM, DPCM, ADPCM

PCM is for audio applications

Pulse Code Modulation (PCM) 脈衝碼調變 (Wikipedia)

- μ-law PCM - USA/Japan
- A-law PCM - Europe

- Linear PCM (LPCM)
- Standard of compact discs and WAV files.

Differential PCM (DPCM) 差值脈衝編碼調變 (Wikipedia)

Adaptive DPCM (ADPCM) 適應性差值脈衝編碼調變 (Wikipedia)