用 Octave 对音频文件进行基本数学的信号处理

2016/10/14 17:56

`R(t) = S1(t) + S2(t)`

```>> sig1='cos440.ogg';                  %creating the audio file @440 Hz
>> sig2='cos880.ogg';                  %creating the audio file @880 Hz
>> fs=44100;                           %generating the parameters values (Period, sampling frequency and angular frequency)
>> t=0:1/fs:0.02;
>> w1=2*pi*440*t;
>> w2=2*pi*880*t;
>> audiowrite(sig1,cos(w1),fs);        %writing the function cos(w) on the files created
>> audiowrite(sig2,cos(w2),fs);```

```>> [y1, fs] = audioread(sig1);
>> plot(y1)```

<

```>> [y2, fs] = audioread(sig2);
>> plot(y2)```

```>> sumres=y1+y2;
>> plot(sumres)```

```>> [y1,fs]=audioread('avemaria_.ogg');
>> plot(y1)```

```>> [y2,fs]=audioread('hymnus.ogg');
>> plot(y2)```

```>> y='avehymnus.ogg';
>> audiowrite(y, y1+y2, fs);
>> plot(y)```

`R(t) = S1(t) * S2(t)`
```>> sig1='cos440.ogg';       %creating the audio file @440 Hz
>> sig2='cos880.ogg';                  %creating the audio file @880 Hz
>> product='prod.ogg';                 %creating the audio file for product
>> fs=44100;                           %generating the parameters values (Period, sampling frequency and angular frequency)
>> t=0:1/fs:0.02;
>> w1=2*pi*440*t;
>> w2=2*pi*880*t;
>> audiowrite(sig1, cos(w1), fs);      %writing the function cos(w) on the files created
>> audiowrite(product, y1.*y2, fs);    %performing the product
>> plot(yprod);                        %plotting the product```

```>> fs=44100;
>> t=0:1/fs:0.03;
>> w=2*pi*220*t;
>> y1=cos(w);
>> plot(y1);```

```>> y2=cos(100*w);
>> plot(y2);```

`>> plot(y1.*y2);`

一个信号和一个标量相乘

`R(t) = K*F(t)`
```>> [y,fs]=audioread('cos440.ogg');        %creating the work files
>> res1='coslow.ogg';
>> res2='coshigh.ogg';>> res3='cosinverted.ogg';
>> K1=0.2;                                %values of the scalars
>> K2=0.5;>> K3=-1;
>> audiowrite(res1, K1*y, fs);            %product function-scalar
>> audiowrite(res2, K2*y, fs);
>> audiowrite(res3, K3*y, fs);```

`>> plot(y)`

`>> plot(res1)`

`>> plot(res2)`

`>> plot(res3)`

0
0 收藏

0 评论
0 收藏
0