In this article I want to talk about my algorithm of a drum machine based on a neural network. The drum machine is designed to create and edit repetitive musical percussions. A classic example of a drum machine is the drum machine from the Roland campaign (TR-808 and TR-909). Classic drum machines are based on the principle of step-by-step programming and include a sequencer, with which you can make a digital recording of the arrangement, that is, program the instrumental piece. An alternative approach to programming a sequence of hits is the neural network approach. In this case, the drum machine uses a neural network to get repeated beats.
The algorithm of the neural drum machine
Rhythmic batches of beats are obtained after setting up the neural network: determine the classes of neurons and their location in the network with the principle of influence. So it is proposed to use delay neurons and normal neurons. Normal neurons have threshold levels. So if the threshold level is 3, then after 3 input signals, this neuron will trigger and transmit the signal further along the network in accordance with the principle of activity. This principle determines that neurons can have two roles - to be both active (influencing - to transmit a signal) and passive (receiving a signal). Delay neurons also have a threshold level, which is the time interval after which the delayed neuron is triggered after the input signal arrives. The time interval in this case is measured in cycles of the neural drum machine. A third type of neuron is also introduced - pacemakers neurons. They also have a threshold level, which is measured in cycles of the drum machine and determines the period of their operation.
The construction of the control neural network should begin with the inclusion of the pacemaker neurons in the network. They are always only active. After them, normal neurons and delay neurons can be embedded in the network. The output signals of all neurons have a unit value. When propagating signals from pacemakers to final neurons at the moments of neuron activation, samples corresponding to neurons are reproduced. ')
Software implementation
In the role of samples can be arbitrary sounds, such as guitar or drums. Therefore, each neuron is assigned a sound fragment from a file.
Neuron sound priorities are also set. This is necessary to exclude overlap of samples. Also, playing a sample of a neuron can be turned off or its volume can be changed. This is relevant if you want to create part of the control neural network, while the final passive neurons will play the sound.
After setting up the network, the value of the unit of time or the speed of the drum machine is determined.
In the program to establish or remove a link you need to select the active node by clicking on it, and holding the Ctrl + Z keys click on the passive node.
Work examples
The neural network principle of programming a sequence of impacts allows sometimes interesting patterns to be obtained.
Examples of the use of such patterns after a little processing can be heard in the following tracks: here and here .
An example of a drum machine can be seen in the following video: