Feeds:
Posts
Comments

Posts Tagged ‘sound files’

Many changes. (1) New name –sf2a (2) source code is at github. (3) At github click on download button if you wish to download. (4) Installation on mac: untar or unzip downoaded file, cd to the resulting folder, run sudo sh setup.sh -install YOUR_USER_NAME; (5) after install, run sf2a 'do re mi' A file out.wav should be created. This is the audio file. (6) There is a musical dictation program, dict that creates audio files and a web page for dictation exercises based on the data in a text file. Use the file dictation.txt in the install folder for an example. Just run dict -m in that folder, then open the web page index.html. (7) For a draft manual, see this web page.

All this works on a mac. Adapting it to Linux is easy. Just change the values of $INSTALL_DIR and $BIN_DIR in setup.sh. I don’t know enough about PC’s to advise on this — one ought to be able to modify the file setup.sh

Advertisements

Read Full Post »

A 440

We will use the magic of unix to make a tuning fork

1 | 2 | 3 | 4 | 5 | Source Code

Things are a little slow at the shop these days – the aftermath of getting our big software development project done. With some time to spare, I’ve been reading The Audio Programming Book, edited by Richard Boulanger and Victor Lazzarini. As a substiture for note-taking as I work my way through this excellent text, I’ve to decided to blog about it.

The first task, from Chapter 1, around page 162, is to write a playable file for the sound of a tuning fork. The end result sounds like what you will hear if you click this link:

OUR FIRST SOUND

Wasn’t that nice? You did play it didn’t you? Here is how we did it – proceed only if you speak C and enjoy the power and elegance of Unix:

Step 1. Compile the program tfork.c using gcc tfork.c -o tfork. You will find it on the CD in chapters/01..., or here. Then execute this command:

./tfork tfork.txt 1.0 440.0 44100 0.2

The result is a 44,000 line text file, tfork.txt, whose first three lines are as follows:


0.00000000
0.06277625
0.12529051

It looks like this:

Tuning fork sound: A 440, exponential decay.

The file represents a sine wave at 440 Herz that decays exponentially to a small fraction of the starting amplitude after 1.0 seconds. The sample rate for the sound is 44100 Herz. The tfork command is used this way:

./tfork outfile duration frequency sample_rate decay_constant

Step 2. Compile the code in text2sf.c and install the binary somewhere in your search path. Execute the command

text2sf tfork.txt tfork.wav 44100 1 1.0

You now have a one-second CD-quality “recording” of a tuning fork! It is in the file tfork.wav You can play it using whatever means suits you and your computer best. On a mac, the command

play tfork.wav

works fine.

Isn’t it interesting that a sound can be represented so many different ways? As a list of numbers, that is, a text file. As an image. As the digital sound file that the computer can directly play. As vibrations in the air that tickle the hair cells in our inner ear. As a memory …

There must be some deep philosophical meaning in all this.

HH

PS. Related links: Barry Threw: Art and Technology

Read Full Post »