Constructing a sampler, pt. 1

Starting way at the bottom, a digital sampler is basically a computer system with a few basic features:

  • Memory for storing sounds
  • An analogue-to-digital converter for getting sounds from the real world into memory
  • A digital-to-analogue converter for getting sounds from the memory into the real world
  • A method of playing back sound from the memory at will in a musically useful way (ie., triggers, MIDI notes)

(You can of course bypass the ADC and just pre-load the memory with sounds, in which case you get a sample-based synth or ROMpler)

This is very similar to a digital delay or looper such as Clueles, of course, which also stores sounds in memory and plays them back again, only such a system dispenses with the ‘at will’ part and just plays back everything in the order it came in.

If we modify the basic algorithm described in the Clueless document, instead of the simple three-step sequence, we need some state to know if we’re recording, playing back, or not doing anything. Ie.,

repeat: {
  if(RUNNING) {
    if(RECORDING) {
      write(buffer[addr++]);
    }
    else {
      read(buffer[addr++]);
    }
  }
}

This obviously doesn’t have a user interface to change the state so it’s not much fun if you run it on a PC, but if we make an implementation with digital logic, we can implement the state by reading from e.g. a pair of flip-flops controlled by simple buttons. By ANDing the sample clock with the flip-flop which represents the RUNNING variable in the code above, the counters are only incremented when the flip-flop is on, We probably only want to fill or play the buffer once on every trigger, so we connect the overflow from the address counters to the reset of the flipflops, meaning that when we reach the end of the buffer, playback or recording stops. In code, this would mean resetting addr to 0 once it reaches the end of the buffer.


repeat: {
  if(RUNNING) {
    if(RECORDING) {
      write(buffer[addr++]);
    }
    else {
      read(buffer[addr++]);
    }
    if (addr >= LENGTH) {
       addr = 0;
       RUNNING = false;
    }
  }
} 

This sampler has some serious limitations, of course: It can only store one sample and it can only play it back from the very beginning to the very end. A variable clock would allow for simple repitching, much like varying the playback speed on a delay or tape recorder.

The addition of a trigger circuit so you could enable recording but only start it after the input reaches a certain threshold would arguably make it useful for sampling percussive noises. A use case for this is making drums with monophonic synths without using a whole synth for a single drum sound; it’s also possible (and easy) to add battery-backup to SRAM, meaning that you could have non-volatile sample storage.

I’ve attached a schematic sketching the above design, minus this trigger circuit. Note that it is untested not all signals are properly connected and that buttons, clock, analogue circuitry, etc., are not shown. The Clueless schematic is more complete if you want to try to build this, but most things should be obvious.

I’ve used a 112 dual J/K flip-flop for the state, push buttons could obvious be attached more or less directly to this. The ‘112 has two outputs per flip-flop: one that’s high when the flip-flop is on, and one that’s high when it’s off. Since the DAC write strobe is derived from the high-when-on output, we can use the other output for the chip select of the DAC, and conversely for the ADC.

It seems that the sequencing parts of Clueless can be entirely foregone since the DAC and ADC aren’t sharing the memory bus, By NAND’ing the clock with the output from the flip-flops, we offset the sample counting pulse (triggered on a rising edge) and the R/W pulses (falling edge). Once again, this is untested, no fitness implied, etc., etc. Do let me know if you try it, though.

bang02

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s