Install GnuRadio and open an untitled.grc flowchart. We populate it with blocks and connect them like any other flowchart. But the connecting arrows are like circuits carrying digital values from block to block.
Your first GnuRadio FlowchartYou may want to save your flowchart. Make a folder, save give it whatever name you wish, the flowchart will have .grc extension for Gnu Radio Companion. The flowchart is actually quite a small file and can be moved between computers.
Now double click on the function box named Variable change the Value to 64000. This will make your PC sample the microphone at 64000 times a second instead of the default 32000. Click OK to close.
Locate the search magnifying glass on the right side of the toolbar. Type in signal source. Hit enter or pull the words Signal Source onto the middle of the flowchart.
Double click Signal Source block. The default is for this block to generate an Output Cosine signal in complex numbers. Notice the blue out connector on the block.
Change this to Output float type values. We will come back later and make more changes.
Find the Audio Sink block and add it to the flowchart.
Since the out of the Signal Source and the in of the Audio Sink are both orange they are both working with float type values. Click on one connector and drag the line over to the other, connection should be automatic. Black for good connection, red for bad.
Ready to make soundYou see the "PLAY" button triangle at the top? Click on it and we should hear a sinusoidal tone at 1000Hz from the speakers of the computer. The Audio Sink block could be set to any audio interface on the computer. The default is the normal sound output.
In addition to the "PLAY" button triangle, you can press F6 on keyboard or Run->Execute in the pulldown menu.
We will add some GUI Graphical User Interface features later. For now stop the sound by clicking the X to close the "Not titled yet" window or Kill by pressing F7.
If you do not hear the tone, check that your computer plays songs or videos with sound. It is the 21st century and your PC may have many audio connections: microphones, stereo line in/out. Your active sound devices do include Bluetooth and HDMI so your OS may be switched in/out to any one of them.
Add a GUI Graphical User Interface Widget
You may wish to save under a new name. GUI is the technical name for a picture interface as opposed to DOS, CLI terminal box typing interfaces. QT is the package of widgets that we will use.
Find the block for QT GUI Sink
Connect the orange out from Signal Source to the blue in on QT GUI Sink. It turns red because float is a different kind of number from complex. Like a sink in your home it will accept a stream of data pouring into it but the data has to be in the right format.
Double click on the QT GUI Sink change type to float.
That was easy. Good to go. In addition to the "PLAY" button triangle, you can press F6 on keyboard or Run->Execute in the pulldown menu.
You see the added display? It should show that your PC is generating a 1000Hz sinusoidal tone out of your speakers and it is directing a copy of the tone to a software display.
Experiment with the display, there is online documentation to explain the GUI you have chosen. Stop the sound by clicking the X to close the "Not titled yet" window or Kill by pressing F7.
Add a Qt GUI Range WidgetFind the Qt GUI Range box and add to the flowchart.
Double click on the QT Gui Range box. Change ID to freq, Default Value to 100 and make Stop frequency 25000. OK to close.
Double click on Signal Source box change frequency to freq just by typing it in. OK to close. Before, it generated a sinusoid at 1000Hz fixed frequency, now it will use the value of the variable freq controlled by the QT GUI Range widget.
Do you see the slider bar and digit field where you can select the generated audio tone? Adjust to 440Hz. You can type in numbers or use the slider.
Try 5000Hz.
Experiment and find out what frequencies you can hear. Some hearing loss is normal, laptops may have limited speaker systems. Look at the features in the QT GUI Sink.
Is your microphone working?Maybe your PC does not have a microphone. Perhaps it's the mic on your headset that's connected? Check the same sound and audio panels that control the speakers, audio input should be nearby.
Let's add an Audio Source block and see if it does default to the computer microphone. It generates audio at the sample rate of 64000 times a second. Floating numbers are used for the samples.
Add a QT GUI Sink just like the first one. Change it to float numbers and make the arrow connection. Change the name to Microphone.
Play. A changed display should appear with the microphone added. Snap your fingers or slap the table. If you see no response then there is no working microphone at default audio input. Troubleshoot the computer audio.
Run through the range of frequencies that you can hear and go beyond those ranges. The new display is rougher because it contains distortions as the sound echos in the room.
Go to the number field next to the slider and select 100Hz. You should hear this through your speaker and the microphone should pick up the signal.
Move the slider to 500Hz. You should hear a higher pitch frequency. The peaks on the graph will move out from the centre.
And go up to 8000Hz. Much higher frequency. You should hear quite a difference.
We added the microphone display so we can tell the difference between hearing loss and technology limitations.
DisclaimerBuilding and using this circuit is for entertainment purposes only. It is not a medical diagnostic device. If you have concerns regarding hearing loss consult with a doctor.
Acoustics are affected by many factors: echos, distortions, absorption. Plus, laptop speakers won't give the performance of a modern 5.1 surround sound system.
The signals from the microphone will include echos and distortions as the sound reflects off of walls and delays are added. Plus background noises, etc.
Comments
Please log in or sign up to comment.