This tutorial introduces the most fundamental features of Matsig. It does not try to be a comprehensive documentation, which, unfortunately, does not exist at the moment. If a full understanding of the operation of the classes is required, getting acquainted with the source code is required.
This tutorial is intended to be read interactively, so that the examples are tried out along the way.
Matsig is an object-oriented signal processing class library for MATLAB, intended to simplify operations common in audio signal processing and speech processing. It is designed to be as transparent in use as reasonably possible, so that the syntax (with some notable exceptions) remains more or less identical to the regular MATLAB vector handling syntax.
While the documentation of Matsig is still spotty, to say the least, many functions already have inline documentation. This documentation may be invoked using the help command by explicitly spelling the class name:
>> help signal/cat CAT Concatenate vectors and signal objects Y=CAT(...) concatenates all arguments into a one signal. The arguments may be either signal objects or regular vectors.
Signal objects may be created using the signal function:
>> r=rand(22050,1); >> s1=signal(r,22050) s1 = signal object: length: 22050 duration: 1.000000 s sampling frequency: 22050 Hz beginning time: 0.000000 s validity: all
Existing audio files may be opened using the openwav command:
s2=openwav('kaksi.wav') s2 = signal object: length: 17733 duration: 0.804218 s sampling frequency: 22050 Hz beginning time: 0.000000 s validity: all >> soundsc(s2);
Signals may be plotted using the regular plot command:
>> plot(s2)
Concatenation works using the cat command. Segments of the signal can be extracted using the trim command or by index subscripting:
>> cat(s,s2) ans = signal object: length: 39783 duration: 1.804218 s sampling frequency: 22050 Hz beginning time: 0.000000 s validity: all >> s2a=trim(s2,0.1,0.2); >> s2i=s2(13000:15000); >> plot(s2,s2a,s2i);
Basic MATLAB operations are defined for the objects:
>> s1_1=2.*(s1-0.5);
Whenever necessary, the underlying vector data can also be directly accessed:
>> s1.s(1:5) ans = 0.9323 0.0767 0.6423 0.4876 0.4470 >> s1.t(1:5) ans = 1.0e-03 * 0 0.0454 0.0907 0.1361 0.1814
Time-based indexing may also be used, with the help of at function:
>> s2s = s2(at(s2,0.4):at(s2,0.4)+1023);
Several auxiliary functions have also been defined:
>> len(s2a) % length, in samples >> maxtime(s2a) % time index of the last sample >> scale(s2a,-1,1) % scale the signal between the given values >> taper(s2a,0.01) % taper the ends of the signal using half-hanning windows >> win(s2s,'hamming') % window the signal using given window function
Due to the importance of filtering tasks in audio signal processing, some supporting facilities have been included in Matsig. These may be the most important features of Matsig. First, non-causal filtering has been implemented. See the difference:
>> s3=signal(repmat([ones(1,40) zeros(1,40)],1,20),8000); >> b=fir1(200,400/(s3.fs/2)); >> s3f=filter(b,1,s3); >> plot(s3,s3f);
>> s3f_nc=filter(b,1,s3,'noncausal'); >> plot(s3,s3f_nc);
The annoying non-stationary regions at the beginning of the filtered signal can easily be trimmed out:
>> s3v=valid(s3f_nc); >> plot(s3,s3v);
Basic frequency-domain operations have been defined, with a syntax analogous to the time-domain operations:
>> S3v=fft(s3v); >> plot(db(half1(S3v)));
In addition to the elementary operations, some more specialized functions have been implemented:
>> find_f0(s2a) % find the fundamental frequency ans = 110.8028 s2aw=win(s2a,'hanning'); a_d=dap(s2aw,24); % calculate the discrete all-pole model of the signal
$Id: Tutorial.html 7 2004-02-04 14:39:28Z mairas $