A Basic Vocoder

To round out this chapter, let’s use a vocoder to process the audio file. Go back to the beginning of the Sound Design Project, if you need to, and resurrect this instrument. This time, rather than receiving an amplitude value from the score, we’ll just put 0.5 into the loscil directly:


  instr 1
  audio loscil 0.5, 1, 1, 1
  outs audio, audio
  endin

We’re going to use a vocoder opcode created by Victor Lazzarini as a user-defined opcode (UDO). Go to www.csounds.com/udo and scroll down to the Filters section. There you’ll find a link for the Vocoder opcode. (The other UDOs on this page are well worth exploring.) You can download the Vocoder code to your hard drive, or just copy and paste the text into your .csd file. Put it in the orchestra header section directly above instr 1—below the 0dbfs=1 line and below any global declarations, such as the delay send busses you created earlier in this chapter.

A vocoder needs two audio inputs—a carrier signal and a modulator (speech) signal. The modulator is the “voiced” source, so use the same vocal sample you’ve been using so far in this chapter. Any sound that is rich in harmonics can be used for the carrier; let’s try out Csound’s vco2 opcode, which defaults to a sawtooth wave. These four lines will create a major triad played by sawtooth waves. Put them into instrument 1:


  acar1 vco2 0.3, 200
  acar2 vco2 0.3, 250
  acar3 vco2 0.3, 300
  acarrier = acar1 + acar2 + acar3

Below these lines and below the loscil line playing the vocal sample, insert a line sending your signals to the Vocoder UDO. To make the structure a bit clearer, we’ll also change the name of the signal being sent to outs:


  aout Vocoder acarrier, audio, 200, 10000, 20, 25
  outs aout, aout

Your vocal sample should now be imprinted onto the major triad. The values chosen for the arguments to Vocoder may require a bit of fiddling to get the best sonic result; this is normal for Csound. The code for the Vocoder UDO documents the meanings of the inputs, but the meaning of the kq parameter (filter Q) may not be obvious. A higher Q value gives the filters in the vocoder a narrower bandwidth. If this value is either too low or too high, the speech-like signal emerging from the vocoder will be less intelligible. A value of 20, as shown in the code above, seems to be about right.

You’ll also find that the output of the vocoder drops to a lower level when the Q is higher. You may need to boost the level of the speech input (the amplitude of the loscil opcode, which is set to 0.5 in the code above) in order to produce an optimal output level.

As an experiment, you might try assigning the frequencies of the three vco2 opcodes to p5, p6, and p7 in your score, so that each note in your score can play different harmonies. Here are the edits for the vco2 lines:


  acar1 vco2 0.2, p5
  acar2 vco2 0.2, p6
  acar3 vco2 0.2, p7

And here is a possible score:


  i1 0 4 1.0 200 250 300
  i1 4 4 1.0 225 300 360
  i1 8 4 1.0 250 300 400

You could instead create a vocoder implementation that would accept chords played in real time on a MIDI keyboard, but this project would take us well beyond the bounds of a QuickStart tutorial. If you’d like to give it a try, turn to Chapter 10, “Using Csound with MIDI, OSC, Pd, Python, and Live Audio,” where the basics of real-time MIDI instruments are introduced.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.83.199