Creation and Implementation of Intellige

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

ACADEMIA Letters

Creation and Implementation of Intelligent MIDI Effect


Plug-Ins
Garrett Eckl

Plug-ins are an essential component of any digital audio workstation (DAW), allowing the user
to modify audio and MIDI data in a variety of ways. The relationship between the DAW and a
plug-in is relatively simplistic. As a file is played, data is passed into the plug-in, modified in
some way, and sent through its output. While this stream of data is sufficient for basic digital
signal processing, it provides no musical context on its own. Simply put, the plug-in does
not know what beat the current sample lies within, what key signature the piece is written in,
or any other elements of the macro-composition. However, supplementary information can
often be used to answer these questions, giving plug-ins a level of intelligence that allows
them to react and adapt to the properties of a DAW project. While DAW developers have
already begun incorporating such software into the framework of their applications, such as
Logic Pro’s algorithmically implemented “Drummer” software, the relatively limited amount
of data provided by DAWs makes it quite difficult for third party software developers to create
intelligent, creatively inclined plug-ins. Although this paper will focus primarily on the cre-
ation of intelligent MIDI Effect plug-ins, several of these concepts can be utilized in Audio
Effect plug-ins as well.

1 Keeping track of the beat


One way in which a plug-in can achieve intelligence is through monitoring the current beat
number. This number can then be used for a variety of purposes, such as sequencing through
parameter settings. Imagine a MIDI echo effect that can reset its feedback loop every time a

Academia Letters, July 2021 ©2021 by the author — Open Access — Distributed under CC BY 4.0

Corresponding Author: Garrett Eckl, geckl1@jhu.edu


Citation: Eckl, G. (2021). Creation and Implementation of Intelligent MIDI Effect Plug-Ins. Academia Letters,
Article 2428. https://doi.org/10.20935/AL2428.

1
new measure is reached, or an audio compressor that can clamp down harder on odd numbered
beats. It should be noted that in this context, the term “beat” refers to the base rhythmic unit
of the time signature, not the MIDI beat clock.
Unfortunately, the current beat number is not something that is provided by any major
DAW. Therefore, ancillary data must be used to calculate this value. To do that, the PPQ
position of the given note must first be calculated, representing its overall position within the
project in units of quarter notes (i.e. a PPQ position of 6 represents the 3rd beat of the 2nd
measure of a project in 4/4 time).

Note Position Equation

Buf f erSamplerN umber


N oteP osition = Buf f erP osition +
(60÷BP M )×SampleRate
This equation calculates the PPQ position of the note, where BufferPosition is the PPQ
position of the start of the current buffer, and BufferSampleNumber is the timestamp of the
note within the buffer. Both of these values are provided by the DAW. Once NotePosition
is calculated, it can then be used to determine the beat within which NotePosition lies. This
equation differs based on whether the current time signature is a simple or compound meter.

Simple Meter Equation

N oteposition − M easureP osition


Beat = [ ]%T imeSigN umerator
4÷T imeSigDenominator

Compound Meter Equation

N oteP osition − M easureP osition


Beat = [ ]%(T imeSigN umerator÷3)
12÷T imeSigDenominator
These equations determine the current beat, where MeasurePosition represents the PPQ
position of the most recent bar line, and NotePosition is the PPQ position previously calcu-
lated. Note that the left-hand side of the modulo is rounded down to the nearest integer. It
should also be noted that while MeasurePosition is not assuredly provided by all DAWS, it
is also not needed for projects with a static time signature, as the modulo operator can still
correctly cycle through the beats without it. Therefore, this value should be initialized to zero,
and only modified if the DAW sends a valid value to the plug-in. This assures functionality
in a large majority of scenarios, with the only exception being projects with varying time
signatures running in a DAW that doesn’t provide MeasurePosition.

Academia Letters, July 2021 ©2021 by the author — Open Access — Distributed under CC BY 4.0

Corresponding Author: Garrett Eckl, geckl1@jhu.edu


Citation: Eckl, G. (2021). Creation and Implementation of Intelligent MIDI Effect Plug-Ins. Academia Letters,
Article 2428. https://doi.org/10.20935/AL2428.

2
Once the beat number is calculated, it can be used for any number of things. A typical
setup might utilize a switch-statement to modify plug-in parameters based on the current beat.
Finally, NotePosition can also be used to determine a note’s proximity to the closest beat.

Beat Proximity Equation

2 Denominator
BP = (|(N oteposition–M easureP osition– )×( |%1)×2
Denominator 4
Here, BP represents beat proximity, the distance between a note and the closest beat as
a unit interval (i.e. 1= perfectly on beat, 0= halfway between two beats). This can then be
used to process MIDI notes differently, based on their proximity to a downbeat. Likewise, this
same concept can be applied to audio samples.

2 Monitoring the key


Monitoring the key of a DAW project is less computationally expensive than monitoring beats.
However, it comes with its own set of unique challenges, stemming from the fact that DAWs
provide no direct information regarding the key signature of a track. Instead, this information
can often be found within the incoming stream of MIDI data, encoded into key signature meta
events. These meta events are unique data bits that represent non-MIDI information. Key
signature meta events are designated by the format

FF 59 02 sf mi

where FF indicates a meta event, and 59 specifies a key signature event (McGill University).
02 indicates the number of data bytes to follow, while sf represents the number of accidentals
(positive for sharps, negative for flats) and mi specifies either a major or minor key. This meta
event can be used to determine the tonic quite easily.

Major Key Tonic Equation

T onic = (N umof Accidentals×7)%12

Minor Key Tonic Equation

Academia Letters, July 2021 ©2021 by the author — Open Access — Distributed under CC BY 4.0

Corresponding Author: Garrett Eckl, geckl1@jhu.edu


Citation: Eckl, G. (2021). Creation and Implementation of Intelligent MIDI Effect Plug-Ins. Academia Letters,
Article 2428. https://doi.org/10.20935/AL2428.

3
T onic = ((N umof Accidentals×7) + 9)%12
In this equation, Tonic represents the integer of the corresponding pitch class (i.e. 0=C,
6=F#), while NumOfAccidentals represents the integer provided by the key signature meta
event. Calculating the tonic makes analyzing the relationship between keys easier. This equa-
tion can be used for a variety of purposes, to emphasize tonic notes or suggest potential mod-
ulation progressions for example.

3 Conclusion
Combining the techniques described above with basic music theory concepts can produce
powerfully intuitive tools. Artificially produced melodies, intelligent humanization, and au-
tomatic accompaniment are all within the scope of possibility. These types of plug-ins trans-
form the DAW into a compositional tool in and of itself. They are not meant to replace the
composer, but to supplement their work; analyzing huge amounts of musical information at a
speed no musician ever could.

Bibliography
“Standard MIDI-File Format Spec. 1.1, Updated.” McGill University,

www.music.mcgill.ca/ ich/classes/mumt306/StandardMIDIfileformat.html.

Cambouropoulos, Emilios. “From MIDI to Traditional Musical Notation.” Austrian Re-


search Institute for Artificial Intelligence, Aristotle University of Thessaloniki, 9 Dec.
2005, users.auth.gr/emilios/papers/aaai2000.pdf.

“Tutorial: Create a basic Audio/MIDI plugin, Part 2: Coding your plug-in.” JUCE,

docs.juce.com/master/tutorial_code_basic_plugin.html.

“MIDI Beat Time Considerations.” MajicDesigns, MD_MIDIFile Standard MIDI File Pro-
cessing, 2 Apr. 2020,

majicdesigns.github.io/MD_MIDIFile/page_timing.html.

Academia Letters, July 2021 ©2021 by the author — Open Access — Distributed under CC BY 4.0

Corresponding Author: Garrett Eckl, geckl1@jhu.edu


Citation: Eckl, G. (2021). Creation and Implementation of Intelligent MIDI Effect Plug-Ins. Academia Letters,
Article 2428. https://doi.org/10.20935/AL2428.

You might also like