Saturday, September 25, 2010

virtual musical instrument (VMI) in LabVIEW

Summary: An individual who can whistle with vibrato can be well-modeled by a sinusoidal oscillator, an attack-sustain-release envelope with a moderate attack and release time, and a low-frequency sinusoidal frequency modulation. In this mini-project you will develop code to model the whistler as a LabVIEW "virtual musical instrument" (VMI) to be "played" by a MIDI file.



Objective

An individual who can whistle with vibrato can be well-modeled by a sinusoidal oscillator, an attack-sustain-release envelope with a moderate attack and release time, and a low-frequency sinusoidal frequency modulation. In this mini-project you will develop code to model the whistler as a LabVIEW virtual musical instrument (VMI) to be "played" by a MIDI file.

Prerequisite Modules

If you have not done so already, please study the pre-requisite module Vibrato Effect. If you are relatively new to LabVIEW, consider taking the course LabVIEW Techniques for Audio Signal Processing which provides the foundation you need to complete this mini-project activity, including working with arrays, creating subVIs, playing an array to the soundcard, and saving an array as a .wav sound file.

Deliverables

  • All LabVIEW code that you develop (block diagrams and front panels)
  • All generated sounds in .wav format
  • Any plots or diagrams requested
  • Summary write-up of your results

Part 1: Tone Generator with Vibrato

In this part you will create a basic tone generator with vibrato. The tone generator will be a sinusoid of the form y(t)=sin(ϕ(t)), where the phase function ϕ(t) has the following form (Equation 1):
ϕ(t)=2πf0t+Δfsin(2πfRt) (1)
where f0 is the tone frequency, Δf is the frequency deviation (vibrato depth), and fR is the vibrato rate in Hz. Use the "Play Waveform" Express VI to listen to your end result y(t) , and experiment with the parameters to find suitable values for rate and depth to simulate the sound of a whistler. Refer to the screencast video in the module Frequency Modulation (FM) Techniques in LabVIEW for coding tips for this part.

Part 2: Attack-Sustain-Release Envelope Generator

Create LabVIEW code to generate a time-varying intensity envelope for the overall attack, sustain, and decay of the note. Your code will require attack time and decay time (both in seconds), as well as the total number of required samples, and will produce an envelope composed of three straight-line segments as plotted in Figure 1.

Figure 1: Attack-Sustain-Release envelope
The maximum intensity is fixed at 0 dB, and the minimum intensity is -40 dB. The attack and release times are fixed parameters that you adjust, and the sustain time is "stretchable" depending on the total number of required samples. If you have the inclination, make your envelope generator more robust so that it can handle the situation where the requested number of samples is less than the number of samples required for your attack and release intervals.

Part 3: Attenuator

Create LabVIEW code that accepts an "amplitude" parameter in the range 0 to 1 and converts this parameter to attenuation in the range -40 dB to 0 dB. The amplitude parameter will ultimately be supplied by MIDI_JamSession and represents the MIDI "note-on" velocity. Your code will map linear velocity onto a logarithmic intensity.

Part 4: Overall Amplitude Envelope

Combine the code fragments you developed in Parts 2 and 3 to create an overall intensity envelope. Remember that when you use intensity values in decibels, you simply add them together. Next, "undo" the equation for decibels to convert the intensity envelope into an amplitude envelope (hint: you need a value of "20" someplace). Choose a representative set of parameter values and plot your overall intensity envelope and your overall amplitude envelope.

Part 5: Whistler VMI

Design a virtual musical instrument (VMI for short) that sounds like someone whistling with vibrato. Your VMI will be played by "MIDI Jam Session." If necessary, visit MIDI Jam Session, download the application VI .zip file, and view the screencast video in that module to learn more about the application and how to create an instrument subVI, or VMI. Your VMI will accept parameters that specify frequency, amplitude, and length of a single note, and will produce an array of audio samples corresponding to a single note. Use the tone generator you developed in Part 1, and apply the amplitude envelope you generated in Part 4. You may wish to keep all of your parameters as front-panel controls and add the "Play Waveform" Express VI to listen to your VMI during development. Adjust the parameters to obtain pleasing and realistic settings, then convert the front-panel controls to constants and remove "Play Waveform." Your finished VMI must not contain any front panel controls or indicators beyond those provided in the prototype instrument. Choose a suitable MIDI file and use MIDI_JamSession to play your whistler VMI. MIDI files that contain a solo instrument, slow tempo, and long sustained notes likely produce better results, for example, Johann Pachelbel's "Canon in D." TryPachelbel_Canon_in_D.mid at the Classical Guitar MIDI Archives. You can also find a more extensive collection at ClassicalArchives.com, specifically Pachelbel MIDI files. Create a .wav file of your finished work.

Optional: Modifications to Basic Whistler VMI

Following are some suggested modifications you could try for your basic whistler VMI:
  • Make the vibrato rate proportional to the intensity envelope. This characteristic is common for vocalists and many types of instrumentalists.
  • Make the vibrato depth proportional to the intensity envelope. This is another characteristic common for vocalists and many types of instrumentalists.
  • Vary either the vibrato rate or depth (or possibly both) according to the "amplitude" parameter provided by the prototype VMI. For example, higher amplitudes could be mapped to a faster rate or more depth.
  • Duplicate the tone generator two more times with frequencies of 2f0 and 3f0 and intensities of -10 dB and -20 dB, respectively, to create some overtones. Each of the tone generators should have the same vibrato rate and depth. The overtones make the whistler sound a bit more like a flute or a singing voice

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Popular Projects

My Blog List

Give support

Give support
Encourage Me through Comments & Followers

Followers