2017/03/18

樂器的ADSR模型

A sound produced by a musical instrument can be explained using the ADSR model, which involves 4 stages:

attack
decay
sustain
release

2017/03/13

Matlab: Length and Size of a Vector/Matrix

Given that

>> a = [1 2 3;4 5 6]
>> b = 1:5

Length

>> length(a)

ans =

     3

>> length(b)

ans =

     5

Size

>> size(a)

ans =

     2     3

>> size(b)

ans =

     1     5

Matlab: How to use Quantiz with partition and codebook

The Quantiz function requires the Communications System Toolbox.
This quantization function requires at least an input signal and a partition vector.

Partition

The example below shows an input signal between 1 and 10. The partition vector equals [2 5 7]. When the signal is quantized, values become:

y = 0 if x <= 2
y = 1 if x <= 5
y = 2 if x <= 7
y = 3 if x > 7

>> x = 1:10

x =

     1     2     3     4     5     6     7     8     9    10

>> partition = [2 5 7]

partition =

     2     5     7

>> y = quantiz(x, partition)

y =

     0     0     1     1     1     2     2     3     3     3


Codebook

Using the same input signal x and partition above, add a codebook as:

>> codebook = [-4 0 2 4]

Insert the codebook as the third parameter in the Quantiz function. The index and quantized value quants are output:

>> [index,quants] = quantiz(x,partition,codebook)

index =

     0     0     1     1     1     2     2     3     3     3


quants =

    -4    -4     0     0     0     2     2     4     4     4



Reference

Quantization (MathWorks)

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)