-
Notifications
You must be signed in to change notification settings - Fork 10
Guided Tour: Music analysis
This is a part of the MiningSuite Guided Tour.
First of all, familiarise yourself with the general capabilities of the MiningSuite for signal processing by checking the Guided Tour on Signal Processing.
You can load a MIDI file and display a piano-roll representation:
mus.score('song.mid')
You can select particular notes, for instance the first 10 ones:
mus.score('song.mid','Notes',1:10)
or the first 5 seconds:
mus.score('song.mid','EndTime',5)
An audio recording can also be transcribed into a score, although the methods are very simplistic for the moment:
mus.score('test.wav')
More there
You can turn a MIDI representation into a signal that can then be further analysed using SigMinr. For instance let's extract the pitch curve from a melody:
p = mus.pitch('song.mid')
We can then compute the histogram of that curve:
sig.histogram(p)
Similarly, we can compute the pitch-interval between successive notes:
p = mus.pitch('song.mid','Inter')
and compute the histogram of this new curve:
sig.histogram(p)
If we sample the pitch curve regularly:
p = mus.pitch('song.mid','Sampling',.1)
we can then compute the autocorrelation function to detect if there is a periodic repetition in the pitch curve:
sig.autocor(p)
We can try to detect the tempo of a piece of music:
mus.tempo('test.wav')
This operations is performed more or less using operators we already studied above. So here is a simplified explanation:
- First extract the event detection curve using a particular method called
'Filter'
:
o = aud.events('test.wav','Filter')
- Compute the temporal differentiation of this curve to emphasise the ascending and descending phases:
do = aud.events(o,'Diff')
- Compute an autocorrelation to detect periodicities in the curve. We use a
'Resonance'
option to emphasise particular frequencies that are easier to perceive:
ac = mus.autocor(do,'Resonance')
- And finally detect the highest peak, corresponding to the tempo:
pa = sig.peaks(ac,'Total',1)
We can estimate the temporal evolution of tempo by adding, as usual, the 'Frame'
keyword:
mus.tempo('test.wav','Frame')
We can perform exactly the same type of operations directly from a MIDI file:
mus.tempo('song.mid','Frame')
For more information about mus.tempo
, click on the link.
Using the method just described, we can also have an estimation whether or not the pulsation is clearly present in the recording or more subtle. This is called pulse clarity, represented by a value that is higher when the rhythmic periodicity is clearer.
mus.pulseclarity('test.wav')
mus.pulseclarity('test.wav','Frame')
mus.pulseclarity('song.mid')
For more information about mus.pulseclarity
, click on the link.
Let's turn now to tonal analysis. We can first get an estimation of the distribution of pitch classes used in the audio recording by computing a chromagram:
mus.chromagram('ragtime.wav')
As usual this can be computed frame by frame:
mus.chromagram('ragtime.wav','Frame')
And we can do the same with MIDI files:
mus.chromagram('song.mid')
For more information about mus.chromagram
, click on the link.
From the chromagram, we can also have an estimation of the key, or tonality, of the audio recording. The key strength curve indicates the probability of each possible key, major or minor:
mus.keystrength('ragtime.wav')
mus.keystrength('ragtime.wav','Frame')
mus.keystrength('song.mid')
For more information about mus.keystrength
, click on the link.
The highest score, as found by mir.peaks
, gives the best key candidate:
ks = mus.keystrength('ragtime.wav');
sig.peaks(ks,'Total',1)
This can be obtained directly by calling mirkey
:
mus.key('ragtime.wav')
mus.key('ragtime.wav','Frame')
mus.key('song.mid')
For more information about mus.key
, click on the link.
From the key strength curve, it is also possible to assess whether the mode is major or minor. Majorness gives a numerical value which is above 0 if it is major, and below 0 if it is minor.
mus.majorness('ragtime.wav')
mus.majorness('ragtime.wav','Frame')
mus.majorness('song.mid')
For more information about mus.majorness
, click on the link.
A more complex representation of tonality is based on a projection on a key-based Self-Organized Matrix (SOM). You can see in the projection that the most probable key is shown in red.
mus.keysom('ragtime.wav')
mus.keysom('ragtime.wav','Frame')
mus.keysom('song.mid')
For more information about mus.keysom
, click on the link.
Five audio processing operators available in AudMinr are specialised in MusMinr for music:
- whereas
sig.spectrum
provides the general mechanisms for spectrum decomposition andaud.spectrum
includes auditory models,mus.spectrum
adds two music-related operations:- subdivision of the frequency axis into cents:
mus.spectrum('ragtime.wav','Cents')
, - when FFT spectrum is computed on envelope curves for tempo extraction, an emphasis on a range of periodicities best adapted for music can be put:
- subdivision of the frequency axis into cents:
e = aud.envelope('ragtime.wav');
mus.spectrum(e,'Resonance','Max',30)
- similarly, whereas
sig.autocor
provides the general mechanisms for autocorrelation function,mus.autocor
adds the same music-related operation:- when FFT spectrum is computed on envelope curves for tempo extraction, an emphasis on a range of periodicities best adapted for music can be put:
mus.autocor(e,'Resonance','Freq')
-
similarly, whereas
aud.tempo
andaud.pulseclarity
estimate tempo and pulse clarity for general audio applications,mus.tempo
andmus.pulseclarity
specialize in music by adding the same 'Resonance' emphasis. -
whereas
and.pitch
extracts pitch for general audio applications,mus.pitch
specialize in music by representing the results in Cents.