Introduction
The signal-to-noise ratio of an audio signal gives a measurement of the quality of that signal. Signal-to-Noise ratio can be measured in real-time using statistics.
This laboratory shows how to evaluate a model of Signal-to-Noise Ratio measurement using Simulink® and run it on a Texas Instruments C6000 DSP.
Objectives
- Run the Simulink model of signal-to-noise ratio measurement on a PC, to determine the optimum parameter settings.
- Modify the Simulink model for real-time measurement of signal-to-noise ratio using the Texas Instruments C6713 DSK.
- Run the project on the Texas Instruments C6713 DSK with a microphone and computer loudspeakers / headphones.
Level
Intermediate - Assumes prior knowledge of MATLAB® and Simulink. It also requires some understanding of statistics and some knowledge of Texas Instruments DSPs.
Hardware and Software Requirements
This laboratory was originally developed using the following hardware and software:
- MATLAB R2006b with Embedded Target for TI C6000.
- Code Composer Studio (CCS) v3.1
- Texas Instruments C6713 DSK hardware.
- Microphone and computer loudspeakers / headphones.
Related Files
- Powerpoint Presentation - SignalToNoise.ppt
- Simulink Model for Simulation - SignalToNoise.mdl
- Simulink Model for Real-Time - SignalToNoiseDSKC6713.mdl
Simulation
Procedure
Opening the SignalToNoise Model
Start MATLAB 7.3.0 R2006b then open the SignalToNoise.mdl
Viewing the SignalToNoise Parent
The SignalToNoise parent is now displayed. Double-click on the Algorithm box.
Algorithm for Signal-to-Noise Ratio Measurement
The Signal-to-Noise Ratio algorithm is now displayed. Run the model.
Output of the Model
Run the model.
It will be seen that the output of the algorithm (“Unfiltered S/N”) varies from frame to frame. The next step is to fine-tune the algorithm parameters.
Tuning the Simulink Model
The model is run several times to determine the best values of the parameters:
- To evaluate the algorithm accuracy for different frequencies
- To determine the optimal frame length
- To set the optimum delay time
- To evaluate the effect of sampling frequency
- To obtain a consistent algorithm output.
Evaluating the Algorithm Accuracy for Different Frequencies
Change the sine wave frequency from 500 Hz (default) to 1000 Hz then run the model several times. Make a note of the four different meter outputs (S/N Ratio from RMS Signals, Unfiltered S/N, Filtered S/N and Buffered).
Repeat using 1500Hz and 2000Hz.
Question: Does the input frequency of the Sine Wave have an effect on the accuracy of the algorithm? If it does, then it would be useful to put a digital filter at the input to the algorithm to limit the frequency band.
Sine Wave 300 Hz
Change the Sine Wave Frequency to 300Hz then run the model.
Make a note of the accuracy of the model.
Changing the Frame Sizes
Increase the Samples per frame to 1024 in both the “Sine Wave” and the “Random Source” Blocks.
Run the model again.
Question: How does this change to the frame size affect performance?
Setting the Delay Value
Click on the “Delay” Block. Change the number of Delay (samples) to 50.
Run the model again and make a note of the accuracy of the measurement.
Change Delay (samples)1 to 12 and run the model again.
Question: How does the value of delay (samples) affect the accuracy of the model?
Changing the Amount of Noise Present
Reload the original model to restore the initial settings.
Change the amount of Gain to make the gain 0.10 (10% noise).
Run the model and make a note of the accuracy of the measurements. Repeat, but this time, use a gain of 0.01 (1% noise).
Question: Does the algorithm work better for high signal-to-noise ratios or for low signal-to-noise ratios? Make a note of the answer.
Changing the Sampling Frequency
Change the sample time in both the “Sine Wave” and the “Random Noise” blocks to 48000 Hz.
Run the model.
Question: Does the model produce better results with 8000Hz sampling or 48000 Hz sampling? Make a note of the answer.
The Fully Optimized Simulation
You should now know what are the optimum parameters for the simulation.
Set these parameters and run the model.
Summary of Simulation
You have now run the signal-to-noise ratio model and should be aware of the best settings for consistency of measurements, delay and sampling frequency.
You are now ready to go to the C6713 DSK Model.
Real-Time Model for TI C6713 DSK
Texas Instruments C6713 DSK Setup
Alternatively, you can use computer loudspeakers.
Starting Code Composer Studio
There are several stages required in order to implement the Signal-to-Noise measurement. These are now described.
Starting up Code Composer Studio
Start Code Composer Studio for C6713 DSK and use Debug -> Connect
The Texas Instruments C6713 DSK Model
You will now use the knowledge you have gained during the PC Simulation to produce an optimized version of this algorithm for use with the Texas Instruments C6713 DSK.
Opening the C6713 DSK Model
Open the SignalToNoiseDSK6713.mdl.
The parent is shown in Figure 15.
Double click on the “function()” block.
Viewing the Signal-to-Noise Measurement Algorithm
The details of the C6713 Algorithm are shown in Figure 16.
Setting the Sampling Rate and Frame Size
Double-click on the “Mic In C6713 DSK ADC” block.
Set the Sampling rate (Hz) and Samples per frame fields to the best value you found while carrying out the Simulation. The values may be different to those written here.
Setting the Delay Size
Double-click on the “Delay” block. Set the Delay (samples) to the best value found during simulation. The value will not be 999!
Returning to the Parent System
From the Toolbar, select the “Up Arrow” icon. This returns you to the next higher level.
Building the Model
Selecting Real-Time Workshop
Select Tools -> Real-Time Workshop -> Build Model.
The Completed Model Running on Code Composer Studio
From the folders on the left, select the source code for the project.
Different Settings on the C6713 DSK
Microphone Straight Through to Loudspeakers
To check out the microphone and loudspeakers, set the DIP switches on the C6713 DSK as follows:
The microphone is fed directly to the loudspeakers. There is no noise gate.
Switch Position for the Audio Noise Gate
To run the Audio Noise Gate, set the DIP switch to 1.
Note that when you are not speaking, there is no audio output at all – just silence.
Modifying the Model
The next stage is to modify the model. You can change the smoothing filter. If the filter is too long, the delay will be noticeable.
Changing the Filter Type
Double-click on the “Lowpass” block. Change the Order to a value other than 10.
Re-building the Model
Select Tools -> Real-Time Workshop -> Build Model.
Running the Updated Model
Run the updated model and listen to the effect on the audio noise gate.
Some Things to Try
You may wish to experiment with different settings. Here are some suggestions.
Add an Input Filter
While running the Simulation, you will have noticed that the Signal-to-Noise Algorithm works better on some frequencies than others.
Add the appropriate filter to select only the frequencies where the algorithm works well.
Process Stereo Inputs
Change the input from “Microphone” to “Stereo Line Input”.
Add a second channel to make the processing stereo.
Best Signal Selection
When stage 3.2 has been completed, modify the model so that the output is the better of the two stereo inputs.
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.
0 comments:
Post a Comment