Applied Speech and Audio Processing: With matlab examples
Download 2.66 Mb. Pdf ko'rish
|
Applied Speech and Audio Processing With MATLAB Examples ( PDFDrive )
- Bu sahifa navigatsiya:
- 7.7. Stereo encoding
Advanced topics
Figure 7.7 Diagram of angle-of-arrival of sound from a single source at distance d and angle θ causing a path distance difference for sound reaching the two ears. If we also denote the head radius as h (thus the distance between the two ears as 2h), then we can use the cosine rule to calculate exactly the path difference travelled by audio reaching each ear. l 2 = d 2 + h 2 − 2dh × cos(π/2 + θ) (7.10) r 2 = d 2 + h 2 − 2dh × cos(π/2 − θ). (7.11) Then assuming location at sea level where the speed of sound is approximately 350 m/s, sounds will reach the left ear in l /350 s, and the right ear in r/350 s. At a sample rate of Fs samples per second, the difference in number of samples between the two would be Fs × 350/(l − r). In Matlab we could then replay a sound, in stereo, with one of the channels delayed by this many samples to cause the brain to interpret the sound as coming from angle θ. We use precisely this calculation in the following Matlab code to simulate a sound moving around the head, additionally with a rudimentary scaling system whereby the amplitude heard by each ear is inversely proportional to the distance to the simulated sound source (so that the ear closer to the sound hears a slightly higher amplitude signal than the one further away): d=5; %distance h=0.1; %head radius Fs=44100; Ft=600; note=tonegen(Ft, Fs, 0.10); note=note+tonegen(Ft*2, Fs, 0.1); 7.7. Stereo encoding 187 %Speed of sound Vs=350; %m/s ln=length(note); %Cosine rule constants b2c2=dˆ2 + hˆ2; b2c=2*d*h; for theta=-pi:pi/20:pi %Calculate path differences lp= b2c2+b2c*cos((pi/2)+theta); rp= b2c2+b2c*cos((pi/2)-theta); %Calculate sound travel times lt= lp/Vs; rt= rp/Vs; %How many samples is this at sample rate Fs ls= round(Fs*lt); rs= round(Fs*rt); %Handle each side separately if(rs>ls) %right is further df=rs-ls; left=[note, zeros(1,df)]/ls; right=[zeros(1,df),note]/rs; else %left is further df=ls-rs; left=[zeros(1,df),note]/ls; right=[note, zeros(1,df)]/rs; end %Create the output matrix audio=[left;right]; soundsc(audio, Fs); pause(0.1); end 7.7.3 Stereo encoding Stereo is normally stored simply as either interleaved left and right samples, or as a two-column matrix as in Matlab, but in professional audio fields, there are far more possibilities. Infobox 7.1 describes some of these. Within audio systems, the traditional approach is to maintain left and right channels as separate streams of data. Gain, filtering, and so on, would be performed independently on each. However, systems which purport to enhance stereo separation, surround sound systems and spatial audio systems would each mix together the stereo channels with different, possibly dynamic, phase relationships. In compression systems, it is also com- mon to encode stereo channels jointly. In many cases this is simply to encode middle and side channels, created from the difference between the left and right channels, separately |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling