Wednesday, August 12, 2009

16. Project Status #4

I've replaced my temporary fix for those clicking noises with a more elegant, permanent fix.

The next features in the pipeline:
  1. Rotating controllers changes frequency (rotating generators already does this)
  2. New controller: Envelope generator
  3. New controller: Sequencer
At the suggestion of a friend, I got Foundations of Computer Music from my local library, but I have to admit it's slow going. I'm definitely missing some prerequisite knowledge.

Saturday, December 20, 2008

15. Project Status #3

Much has happened since my last update. In December, the camera arrived, and I wrote the connection manager, integrating the basic synthesizer I had written. By the end of December I was making the same funny noises, but now moving objects around on the tabletop. Then, around Christmas-time I ran into a tricky problem. I added a rotation action to my generators, which changes frequency. (ie. you turn the object to change it's pitch) However, rotating caused terrible clicking noises. Despite some friendly offers of help, I lost interest in the project. Just tonight, three months later, I sat down for a few hours and came up with a workaround!

So, I'm happy to report that I'm not done with this project yet.

Tuesday, December 2, 2008

14. First generated sounds

I've added support for generators to have multiple controllers. I recorded some simple sounds to share with you.

First, a sinewave generator with 4 sinewave controllers of various frequencies.

Second, a mix of a bunch of different waveforms. There's a sawtooth controller in there, one or two square wave controllers, and I think the generator was square wave also.

I know, these are really trivial examples of synthesis, but I'm just getting started. Maybe I'll write a step sequencer next. Then I can actually make some beats.

Tuesday, November 25, 2008

13. Endianness Conversion

The following are two common tasks I have been dealing with, except I haven't been using the appropriate bitwise operators for efficiency. These examples were a big help:

How do I convert short (16 bit) samples to bytes to store them in a byte array?

Example: Store 16-bit sample in a little-endian byte array:
short sample = ...;
byte[] buffer = ...;
int offset = ...;
// low byte
buffer[offset + 0] = (byte) (sample & 0xFF);
// high byte
buffer[offset + 1] = (byte) (sample >> 8) & 0xFF;

How can I reconstruct sample values from a byte array?

Example: Reconstruct a 16-bit sample from signed PCM into a signed int (32-bit):
int sample = (buffer[offset + 0] & 0xFF) | 
(buffer[offset + 1] << 8);

Note the bitwise inclusive OR (|) and the signed left shift operator
(<<). The bitwise AND (&) I was already using to mask, as above,
but the other two I wasn't using yet. I was using integer arithmetic
instead of these bitwise operators, which is a little embarrassing.

12. Endianness

Endianness of components in my project:
  1. The Java virtual machine is big-endian. (citation needed)
  2. My Intel-based mac is little-endian.
  3. "PCI busses are, by design, little endian" (citation) (Not applicable in my situation because my audio is on-board, but interesting to know.)
  4. My macbook's audio device is probably this: "Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 02)" which I assume is little-endian, because it is from Intel. (This is someone else's output from lspci, which I don't have installed)
  5. The examples I've seen so far at are little-endian

I am using 16-bit samples, but if you are only using 8-bit, you can ignore endianness:

For Java Sound, endianess matters if the size of samples (as given by AudioFormat.getSampleSizeInBits()) is greater than 8 bit. For 8 bit data, while the endianess still has to be specified in an AudioFormat object, it has no significance.



I can perform audio synthesis calculations in big-endian, because that is what the JVM speaks, but my final output should be little-endian, because that is what all of my Intel hardware speaks. Obviously, I should only convert once, for the final output.

Monday, November 24, 2008

11. Project Status #2

Working from the other end of the project, so to speak, I've written a proof-of-concept tree. So far I have a generator and controller.

So, instead of making the beeeeeeeeeeeeeeeeeeep of the generator, now I can make a beep beep beep. (with a square wave controller) I can also use a sine or triangle controller to make a woo woo woo, or a sawtooth controller to make a chirp chirp chirp. It's a big step for me!

The next step is to support more than one controller, so I can make a beep beep beep BEEP beep beep beep BEEP.

Before I can do that, I need to clean up my code, fix a bug in my two's complement math, and get some sleep.

Tuesday, November 18, 2008

10. Building tabletop and cabinet

I got a glass table top for free. Woot. I traced the table top onto paper. Drew arcs. These arcs will be patterns for cutting the plywood. Actually, I will be making two rings out of these arcs. The bottom ring will be a lip for the glass to rest on. You'll see.

I cut out the arc patterns. The left over paper circle below the glass shows usable area. Cell phone shown for scale.

Getting ready to glue arcs into rings. See how there are two rings? The rings overlap for strength.

Gluing arcs. Yay clamps!

Planning the cabinet ..

Simple cabinet out of 2x2s and 1x4s. It's actually quite sturdy, and lightweight. I'm satisfied.

To make the table more portable, I want to be able to take the top off. I use bolts, eye straps, and wingnuts.