Music2Light (M2L) |
Previous Next |
IntroductionMusic2Light effects can go a step further and analyze music regarding music theoretical aspects. Tonality, scale, or intervals are only some examples of the data that can be retrieved by the sound analysis. This chapter describes how to retrieve the data provided by MADRIX. However, it does not describe any music theory.
Using Tonality And ScaleLet us start with tonality and scale of a chord. The two can be retrieved via the functions GetTonality and GetToneScale, respectively. The exemplary sample source code for the MAS Script Effect below uses tonality and scale to select a color and the alpha value will be the background color. Please remember: an audio input signal is needed. const color g_colorTable[] = { Explanation: ▪The first thing is to create a color table in which each entry equals a tonality. If the tonality is undetermined, the function GetTonality results in -1. ▪Therefore, we have to check if the value is a valid array index and possibly draw a black matrix. You could use the function IsTonality to check if the tonality was set or not.
Using NotesMADRIX is able to identify the notes played in a song. The lowest note that can be evaluated is a C with 8.25 Hz. The highest note is a G with 12.6 kHz. There are two functions available to get information about the identified notes. GetNoteValue retrieves the volume of the given note and IsNote returns 1 (TRUE) if the given note has been detected, otherwise 0 (FALSE). There is the function GetAllNoteValues, which fills an array with the volume of each note. Using this method for a lot of notes is much faster then calling GetNoteValue each time. An overview of which index corresponds to which note is given by the »Table Of Notes The next example for the MAS Script Effect uses played notes to fill the matrix with different colors. It uses only the values of three frequencies of C. void InitEffect() Explanation: ▪First, the levels of the notes are retrieved and normalized to the range from 0.0 to 1.0. Hereby, only three C notes are used. ▪Then, a color is initialized and the matrix is filled.
Using IntervalsThere are similar functions to get information about the intervals indexed from 0 (small second interval) to 10 (large seventh interval). The function IsInterval returns 1 (TRUE) if the specified interval could be analyzed, otherwise 0 (FALSE). Again, the function GetAllIntervals fills an array rapidly, each element with either 1 (TRUE) (interval was analyzed) or 0 (FALSE) (interval was not analyzed). The following short example for the MAS Script Effect clarifies the usage of GetAllIntervals: const int middle=GetMatrixHeight()/2; Explanation: ▪At first, in InitEffect the buffer buf is filled once, just in order to get the buffer length. With the buffer length, a horizontal distance xStep is calculated to separate some lines equally later on. Using the function max, the distance is at least 1. ▪Calling RenderEffect the buffer buf is filled with the current interval occurrences. Then, a vertical line is drawn for every interval, either from the middle to the top of the matrix (if the interval was analyzed) or from the middle to the bottom (if not analyzed).
Using Other Tone Theoretical ParametersThere is lots of other data which may be used to create effects, e.g. the sound level or the note of the currently lowest note (bass tone). The handling is similar to the functions described above. Further details are given in the »List Of Functions
|
MADRIX Version: 5.7 | Script Version: 3.23 |
[Ctrl & +/-] = Zoom In/Out | [Ctrl & 0] = 100% |
Previous
Next
|
Enable automatic translation | Activer la traduction automatique | |