True binaural recording uses stereo mics pointed outwards from inside your ears to capture as closely as possible the exact sound pressure waves entering your ear canals. The binaural technique captures filter (transfer function) differences caused by body parts shadowing and reflecting sounds arriving from various directions: the ear flaps (pinnae), head, shoulders, etc. Played back over headphones or earbuds, binaural preserves the interaural loudness and timing difference (ILD and ITD) cues which are basic to sound localization.
In this part of the assignment, we'll use four channels of sound (giving you a much wider plane of possible locations for your sound sources - essentially, two in front of your listener and two behind, as in the quad speaker setups at CCRMA) and process those quad signals into a file for posting to the homework factory.
Before you jump into the world of 4-channel sound systems, you'll need to have a channel test tool for sanity's sake, and equipment that has more than two output channels. Several CCRMA workstations are equipped for multichannel while your laptop may only be set up for two channels. Laptops will also need audacity, qjackctl, sox, and miniAudicle. If you do not want to go through this hassle of downloading and setting up additional software, feel free to use one of the CCRMA stations with a quad system.
In this section, we demonstrate how to run a quick test to make sure we're hearing all four channels. At a quad station with a linux computer (or on any computer where you hear all four channels, even if they are mixed to stereo via headphones) launch qjackctl (the control panel for Jack) and prepare its setup to be connected to the appropriate soundcard. You can launch with the following command in terminal:
qjackctl &
NOTE: If you're working at a house linux computer with a Tascam quad soundcard and you are listening via headphones, you will still hear all four channels but the second (rear) pair will be mixed in and "hard-panned" left and right.
Hit start. You're good if the GUI starts showing a changing computer status (otherwise, you will get a complaint popup). Sound is now live.
Download and open DacBeeps.ck in miniAudicle. In miniAudicle preferences, set output channels to 4, then start the virtual machine. Whenever you change something in "preferences" the virtual machine will need to be restarted to have the changes take effect.
Preferences > Audio > Output Channels > 4
Or if you are executing chuck from the command line use
chuck --channels:4 DacBeeps.ck
Add the shred and adjust speaker levels for reasonable balance. You should get one beep for speaker 1, two beeps for speaker 2, etc. up to four. When your'e hearing that, congratulations! You are now working in a world of multichannel.
You can now send sounds not only from left to right and from right to left, but pan from behind your left shoulder to in front of your left shoulder, or diagonally across your body. (Again, if you're using the quad stations, you'll be able to experience this spatialization fully; if you are using the house heapdhones, and sending sound from channel 1 to channel 3, the sound won't pan at all because they will be sent to the same headphone.) You can address each of these channels by using:
dac.chan(0) dac.chan(1) dac.chan(2) dac.chan(3) ...and note that channel numbering in chuck is zero-based
Note: A good way to pan in ChucK is to shred the DBAP4.ck file and as in this next file, pass .wav file through it that you would like to pan in 4 channel space: DBAP4_ex.ck. The filename is hardcoded and will need to be your own. The line p.setPosition(Math.sin(t),0) can be changed to p.setPosition(Math.sin(t),Math.cos(t)) to send your sound in a circle around all four speakers.
This section details the steps necessary to convert four audio signals (intended for channels Left, Right, Right-rear, Left-rear) into an ambisonic encoded signal (components W, X, Y, Z). Ambisonics is a format useful for storing audio signals in a format that is agnostic to the playback speaker configuration. We will listen to your final submission through headphones by decoding your ambisonic file with a binaural renderer with the Web audio Omnitone toolbox (same as Youtube now supports).
chuck -s -o4 --srate:48000 quadBeeps2foa.ck
sox -M <your-input-base-file-name>*.wav <your-output-file-name>.wav
Instead of synthesizing beeps, this section describes reading in 4 (mono) .wav files as SndBuf's.
chuck -s -o4 --srate:48000 quadSlates2foa.ck