So the next thing I tried was a combination with my analog synthesizer. I could output a CV signal whose voltage changes depending on the scale when I play the keyboard, and a GATE signal that indicates whether the keyboard is being played or released, so I decided to use this.
Connect with your analog synthesizerWhen I checked with a tester to see if the voltage was properly generated with this analog synthesizer called MicroBrute, it was 1.99V when I played Do, which was almost 2V, and when I played Do one octave lower, it became 1.00V, and it seems to be moving firmly. is. Since it is a standard of Oct / V, it goes up by 1 / 12V by a semitone, and it goes up by 1V in one octave, so I tried to push this into P1.
I checked it with a tester and found that it was working properly.Looking at the micro: bit side, it is possible to measure 0 to 3V, so it is not good to input 3V or more. However, even if I put in about 5V, the current does not flow, so I decided that there would be no fear of damage.
I tried to input 5VThen, what happens to the important input value, because the voltage will not be measured as it is, I made a simple program that reads the analog value and displays it on the LED, and the result was immediately obtained. .. If you play a low do, it will be 325, 642 one octave up, 959 one octave up, and 317 numbers will go up one octave. If you play the letter above it, it will be 1023 and the upper limit will be reached. In short, it seems that 0 to 3V is sensed with 10bit.
The result was obtained by the program that reads the analog value and displays it on the LED.For the time being, without thinking about difficult things, if you try to make a sound using the read numbers as the frequency, you can play something like that. However, if this is left as it is, the sound will continue to be output, so I put a GATE signal in P2, and if the value is greater than 500, it emits sound, and if it is 500 or less, it stops the sound. Actually, I couldn't find the command to stop the sound, so I set the frequency to 0Hz and played.
Input a GATE signal to P2 Instead of a command to stop the sound, set a frequency of 0Hz. Play by connecting a micro: bit and an analog synth. The pitch is ...If you listen to it, you'll find that it's quite deaf, but it's playing like that. It is a coincidence in a sense that I could set the read value as a frequency and play it like that. However, apart from the lower octave, the upper octave is already messed up. Well, I was able to realize that if you press the keyboard, the sound will be heard, and if you release it, the sound will stop.
I was happy that the sound came out, but ...So I immediately tried again to program it a little more and make it an instrument that I could play properly. The on / off control of the keyboard by the GATE signal can be left as it is. However, since the pitch is erratic, I have to make sure here.
The idea here is a calculation to derive the correct pitch frequency from the numerical value read by P1. When it receives a low signal, it is 325, and the frequency at this time is 262Hz. It is calculated that the value increases by 317/12 = 26 or 27 for a semitone increase, and there are originally no decimals in the sensing result. However, I wondered if MakeCode could calculate decimal numbers, so I subtracted 325 from the value entered in P1 and divided it by 26.4, and the calculation was successful. The result of rounding this is a numerical value that means how many semitones are raised from the low do. I assigned this to a variable called a.
By the way, since the frequency doubles in one octave, it is calculated that the frequency increases about 1.0594 times for each semitone. In other words, using the factorial calculation, multiplying 1.0594 to the ath power by 262, which is the frequency of do, the target frequency can be obtained. It's complicated to write in sentences, but it's relatively simple in mathematical formulas. However, I couldn't find a function called factorial in MakeCode, so I used a loop instruction to make a program that repeats 1.0594 a times to perform multiplication.
Change and apply the programSo what happens when you play MicroBrute with this?
Performance when the modified program is appliedThis time it's perfect. This program can only play about 2 octaves, but I was able to make it a decent instrument. What's more, I'm a little impressed that it can be done with such a short program. I tried to make a program for the first time in a long time, but it's still fun. I'm thinking about what kind of program I should make next time.
Category
Related Articles
Hot Articles