How to Send Data to a Sound Card in MATLAB

MATLAB has become one of the most popular programming languages for signal processing from anything from sound to brain wave signals. When working with sound, it is desirable to be able to send processed sound signals direct to a computer's sound card for reproduction. Accomplish this easily thanks to the direct support that exists in MATLAB for handling this task.

Instructions

    • 1

      Choose a wave file to use as an example. Any wave file that ends with a ".wav" file extension will work for this experiment. A good example is any music recording downloaded from the Internet. Such files may be found in your "downloads" folder. The wave file you have chosen is sent to the sound card to illustrate how data can be sent to it. In doing so, you hear it play on your computer's speakers.

    • 2

      Determine the sampling rate of your wave file by left-clicking on the file, then clicking the summary tab. An audio sample rate appears in the summary as one of the properties. The sampling rate is rounded off from the standard rates, which are as follows:

      6,000

      8,000

      11,025

      16,000

      22,050

      32,000

      32,075

      44,100

      48,000

      Pick the standard rate closest to that appearing in the Summary tab.

    • 3

      Run MATLAB. The way this is done depends on your computer and your installation of MATLAB; however, you can review the MATLAB installation instructions to find out how to run MATLAB on your particular computer. Once it is running, a MATLAB window labeled "Command Window" will appear and will contain the following prompt, known as the MATLAB command prompt:

      >>

    • 4

      Input the wavefile into a MATLAB variable using the following command at the MATLAB command prompt:

      x=wavread('filename.wav');

      Remember to hit the "Enter" key after typing in the command to cause MATLAB to execute it. Replace the parameter in the above example with the filename of the desired wave file. The variable "x" will now contain the sound recorded in the wave file. In the example, the variable "x" now contains the data that will be sent to the sound card.

    • 5

      Send the sound to the sound card using the following command:

      soundsc(x,44100);

      When you press "Enter" you should hear the wave file play in your computer's speakers. The "44100" in the above example should be replaced with the sampling rate of your particular wave file. The variable "x" may be replaced by any data that you would like to send to the sound card.

Tips & Warnings

  • Data representing signals other than sound can just as easily be sent to the sound card. For example, brain wave signals can be "played" on the sound card to hear what they sound like. For data other than actual sound recordings, the sampling rate should be adjusted experimentally until the sound is satisfactory.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured