Skip to main content

Crate midi_fundsp

Crate midi_fundsp 

Source
Expand description

This crate enables the construction of synthesizers with live MIDI input and sound synthesis using fundsp.

It is organized as follows:

  • The crate root contains functions and data structures useful for constucting fundsp sounds.
  • The io module contains functions and data types for obtaining messages from MIDI devices and playing
    fundsp audio graphs through the computer’s speakers.
  • The sound_builders module contains functions that wrap fundsp audio graphs into SynthFunc functions with a variety of properties.
  • The sounds module contains SynthFunc functions that produce a variety of live sounds.

The following example programs show how these components interact to produce a working synthesizer:

  • basic_demo.rs opens the first MIDI device it finds and plays a simple triangle waveform sound in response to MIDI events.
  • stereo_demo.rs also opens the first MIDI device it finds. It plays notes below middle C through the left speaker using a Moog Pulse sound, and notes at Middle C or higher through the right speaker using a Moog Triangle sound.
  • choice_demo.rs allows the user to choose one from among all connected MIDI devices. The user can then choose any sound from the sounds module for the program’s response to MIDI events.
  • just_tempered_demo.rs shows how to use an alternative function for converting MIDI notes to frequencies. This specific alternative function uses Just Intonation instead of equal temperament.
  • cc_demo.rs demonstrates the use of a sound with properties altered by a MIDI Control Change message. The Control Change channel is specified by a generic constant for the MusicBox sound type. (It is set at 7 in this example because that is a convenient Control Change channel for my own MIDI keyboard.) This illustrates how to build and employ sounds using MIDI Control Change for any application you might imagine.

Modules§

io
sound_builders
sounds
tunings

Macros§

program_table
Convenience macro to build a ProgramTable. Given a sequence of tuples of &str objects and SynthFunc objects, it returns a proper ProgramTable.

Structs§

SharedMidiState
SharedMidiState objects represent as fundsp Shared atomic variables the following MIDI events:
SoundTestResult
When designing sounds, it can be useful to understand their typical output levels. SoundTestResult objects track the minimum, maximum, and mean output levels.

Constants§

CONTROL_OFF
Control value in response to Note Off event.
CONTROL_ON
Control value in response to Note On event.
DURATION
Duration of test for SoundTestResult.
MAX_MIDI_VALUE
MIDI values for pitch and velocity range from 0 to 127.
NUM_MIDI_VALUES
Total quantity of distinct MIDI values.
SAMPLE_RATE
Sample rate of 44.1 kHz for use in SoundTestResult.

Functions§

control_change_from
If a given MidiMsg object is encapsulating a ControlChange it returns the control id and value values of that message.
note_velocity_from
If a given MidiMsg object is a NoteOn or NoteOff message, it returns the note and velocity values of that message.
pitch_bend_factor
Converts MIDI pitch-bend message to frequency multiplier over +/- 1 semitone using this algorithm.
semitone_from
Converts MIDI pitch-bend message to +/- 1 semitone using this algorithm.

Type Aliases§

SynthFunc
SynthFunc objects translate SharedMidiState values into fundsp audio graphs.