|↑↑ Home||↑ Noise|
Short samples are little use for simulating a musical instrument, as repeating one or several waveforms sounds very artificial to the human ear. Longer samples which can be repeated (looped) without any audible artifacts can be generated from short ones by Fourier transforming, stretching Fourier space and reverse transforming. The mksam program does just that. In addition, it allows to interpolate the Fourier coefficients, and to blur the peaks in Fourier space, which creates choir-like sound (see here). For Fourier transforms, the FFTW3 library is used, so its library and header files have to be present for compilation.
Here's the source code for mksam.
The current version automatically recognises a multi-processor/-core system and spawns a number of threads to exploit this when computing convolutions.
The old-school way to play an audio CD on your Linux box is to connect it to your sound card with a cable and use a utility like pcd or playcd. But this has a number of disadvantages: you have to buy the cable, you have to always use the same sound card, and you cannot use ALSA and its advanced features for processing output. The alternative is to use cdparanoia or a similar tool to rip the CD and pipe its output right into a wave file player, for instance the ALSA player aplay:
cdparanoia 1- - | aplay
Doing this, I found that my CD-ROM drive took so long to spin up the CD that this caused buffer underruns for aplay. To solve this problem, I wrote a buffering program fifo (source code here) which first fills its buffer completely, then starts passing data through. Its basic usage for our purpose is:
cdparanoia 1- - | fifo | aplay
(This assumes you installed the executable somewhere in your PATH; otherwise you have to give its path explicitly.) fifo optionally accepts a buffer size and a chunk size on the command line. The latter is the maximum amount of data output to the downstream client (aplay) in one go, which helps to prevent the CD-ROM drive from spinning down during playback. A comment at the top of the source code says how to compile fifo, and a brief usage message can be obtained with fifo -h. fifo probably also has other applications wherever timely availability of streaming data is required.
Here is the source code of a small program which splits .wav files up into parts. It is intended for splitting audio from cassettes and records digitised via your sound card up into tracks. Gramofile is supposed to be the tool for that, but it can do anything but actually split the .wav file. I actually used snd for determining track boundaries by hand, because it takes less time than finding the right parameters to do it automatically ;). snd is actually smart enough not to try loading half a gigabyte of sound data into 386M of RAM. But marking tracks as a block takes forever because you can't mark the start and the end separately but have to pull the mark over the whole track.
PS: I have since found out that there are two packages which can also split or otherwise process wav files: wavsplit is more comfortable to use but seems to have problems with stereo wav files. The wavtools contain a powerful tool, wavcutter, which cannot exactly split wav files but can extract several pieces and concatenate them, and can also deal with stereo.