Kupar 13,341 Posted February 3, 2021 Share Posted February 3, 2021 (edited) Making a theremin control a MIDI synthesizer I can’t claim *any* coding credit here, but I have successfully stitched together a number of components to make a theremin control a MIDI synthesizer on my laptop. This gives me the ability to vastly expand the range of sounds and effects that can be played from the theremin. First: a theremin is a musical instrument that is played without contact and generally makes a very spooky, ‘slidy’ sound. You’ll have heard in in the Beach Boys’ ‘Good Vibrations’ for instance. It’s based on the principle that a heterodyne oscillator can be controlled in pitch through a LC circuit where the capacitance is varied by moving the player’s right hand nearer or further from an antenna. A similar principle is used to control the volume via another antenna with the player’s left hand. I bought an Arduino-based theremin ‘kit’ from the creator of the OpenTheremin project (http://www.gaudi.ch/OpenTheremin/). I use the term ‘kit’ loosely as it came with the extra theremin board (Arduino shield) pre-soldered in place. The only things I needed to do to play it out of the box were: connect the theremin to a power supply (I powered it from the laptop via USB) ground the board with a separate earth wire to the radiator (because the player is the ‘ground’ in the LC circuit, it’s important that the instrument and player are grounded) connect the audio output to an active speaker. The theremin has an auto calibration routine, and pots to adjust timbre (one of eight built-in waveforms), register (how high and low the instrument will play), volume and pitch (you can ‘tune’ it a little – though that’s not particularly useful with this instrument given that there are no absolute notes). However, the eight built-in waveforms are what they are. For much greater flexibility, it’s possible to convert the theremin’s output into a MIDI signal that can be interpreted by a physical or virtual MIDI synthesizer. I chose the MiniMogue VA (https://vst4free.com/plugin/405/). However, the base Open Theremin Arduino code needed replacing with a branch that included the MIDI implementation and Arduino MIDI libraries. This was straightforward even for me (with *zero* experience with Arduino). But there are two further pieces of software required to stitch the theremin output (which comes into the laptop via a USB serial port) to the synthesizer: a MIDI serial bridge (http://projectgus.github.com/hairless-midiserial/), and a virtual MIDI passthrough driver to create the necessary ports (http://www.tobias-erichsen.de/software/loopmidi.html). It took me a while to realise the necessity of the driver; that held up the project for a while. Once all this was in place, the synthesizer could recognise the theremin as the MIDI input and send audio to any audio device (I just plugged some headphones into the laptop). That’s as far as the project has got, other than a very quick play with capabilities of the synthesizer – but as it’s a reasonably faithful implementation of a Mini Moog, I have a lot of possibilities; three oscillators can be used independently to generate waveforms and modify them in many, many ways. The synthesizer’s ability to bend pitch can preserve the theremin’s unique sound, but can add very much more to it – including, for instance, making a series of more-or-less discrete notes if that’s what you want. In parallel with this tech project, of course, is the project to learn to play instrument. I have made a start on this – and have realised the importance of using hand shapes to reliably create whole tone or semitone intervals in a scale, for instance. My right hand is missing a finger, which gives me slightly less of a maximum capacitance change with the hand alone than a ‘normal’ person, but I can just about go up and down a scale with the instrument’s default calibration. If you’ve read this far, thanks! Edited February 4, 2021 by Kupar typo 1 2 Link to post
Sophie 24,412 Posted March 23, 2021 Share Posted March 23, 2021 I'm not sure if this counts or not but I have started working on a GUI for my yourworldoftext pasting script. It's more or less as I want it at the moment (the browse button isn't quite aligned and it's annoying me so much) and things go strange if I expand the window, but it's a start! It will paste whatever I put in the top box, which I can type or copy+paste, or it will take something already written from a text file. In this case, bunnysign.txt ________ | hello! | |_______| | (\(\ | ('-')| ( 3 3 (_")") 1 1 Link to post
Kupar 13,341 Posted March 23, 2021 Share Posted March 23, 2021 1 minute ago, Sophie said: I'm not sure if this counts or not but I have started working on a GUI for my yourworldoftext pasting script. It's more or less as I want it at the moment (the browse button isn't quite aligned and it's annoying me so much) and things go strange if I expand the window, but it's a start! It will paste whatever I put in the top box, which I can type or copy+paste, or it will take something already written from a text file. In this case, bunnysign.txt ________ | hello! | |_______| | (\(\ | ('-')| ( 3 3 (_")") Definitely counts 🙂 I think many people would say something like that is almost the essence of a geeky/nerdy project. And I mean that in a complimentary way of course! 1 Link to post
Sophie 24,412 Posted March 24, 2021 Share Posted March 24, 2021 24 minutes ago, p1ssputz said: Well....if that's your training data, I would recommend using a more varied set of faces. Your image program isn't going to recognize middle-aged, ugly dudes like me. 😂 (Also....I just realized that this year, I think I'll officially be middle-aged. Fuck.) There is no training because there is no neural network, but I get what you are saying 🙂 I would get the same results if I used 10 faces or 10 thousand, actually if anything I would get worse results with more faces because of false positives. If people looked vaugely similar it would lump them into the same folder unless there was already a photo of that person, if that makes sense? and I have over a thousand images to play with if I really wanted to! 🙂 Link to post
Sophie 24,412 Posted March 27, 2021 Share Posted March 27, 2021 Awesome work! Isn't it fantastic when you came quickly, and cheaply come up with solutions like that? 2 1 Link to post
Kupar 13,341 Posted May 9, 2021 Share Posted May 9, 2021 Tomato watering system I have finally finished wiring up an automated irrigation system for my tomato plants so that if we get the chance to go away for a week this summer I will know that my tomatoes will still be alive when I get back. The principle is very simple: a moisture sensor stuck in the growbag, an Arduino nano comparing the measured moisture value against a pre-set value, and if the moisture falls below it, opening a solenoid valve for a pre-set length of time, then closing it. The valve will be connected to a normal garden hose between a water butt and the growbag. The flow rate will be dependent on the head of water in the butt of course, but if I keep the valve-open time reasonably short, there shouldn’t be a risk of flooding anything before the next measurement / watering cycle. Simples. I made the system slightly superior by choosing a capacitance-based rather than a resistance-based sensor (it won’t corrode and should last longer). And the supplier of the sensor has helpfully written some Arduino code as well as providing the circuit diagram. I could have written the code myself, as when I looked at it, it all made perfect sense (which I was pleased about as I am an Arduino novice). Another sophistication is the inclusion of a display to show the measured and set-point moisture values, with push-button adjustment of the set point so this doesn’t need to be done within the code. The valve-open time is set in the code. The only modification I needed to make to the sensor supplier’s circuit was to replace his suggested 9V pump with my 12V normally closed solenoid valve, which required the use of a 12V mains adapter in addition to the 9V battery used for the sensor / Arduino. After two minor delays (realising that my display needed an IC2 interface module soldering to it, and discovering that the MOSFET switching the 12V to the valve was f***ed and I needed to order a replacement), the circuit worked beautifully on the breadboard. As my soldering skills having not been tested properly for about 40 years, I treated myself to a temperature-controlled iron (lovely!) and transferred everything to perf board, giving myself plenty of space because my eyesight and fingers aren’t what they were. And … argh. It still looked like a dog’s breakfast and didn’t work. Cue characteristic self-doubt and catastrophising about how complex it was going to be to correct whatever error I would discover. I found the first problem pretty quickly – a ground connection I thought I’d wired that I actually hadn’t. I connected up the sensor, valve and power supplies, switched on, and … most of the system worked: the sensor and the Arduino doing exactly what they should, sending +5V to the MOSFET when expected. But the switching circuit was wrong somewhere. But a little while checking everything again revealed I’d connected a resistor to the wrong hole on the perf board. Fortunately nothing damaged, and after correcting it – hey presto! So only thing to do now is to house it all appropriately (I think a couple of margarine and ice cream tubs will do the job) connect the hose and that’s it. But given I don’t even have my tomato plants yet, that’ll wait. As in quite a lot of my PeeFans life I am indebted to @Sophie and @gldenwetgoose for encouragement and practical support. This project is the second since I started to fiddle about with nerdy stuff again. Great fun. 2 2 Link to post
Paulypeeps 5,290 Posted May 9, 2021 Share Posted May 9, 2021 Cool. You will be able to write some code now to estimate how much water the plants are using if you can work out the mean flow rate. 1 Link to post
Kupar 13,341 Posted May 9, 2021 Share Posted May 9, 2021 Just now, Paulypeeps said: Cool. You will be able to write some code now to estimate how much water the plants are using if you can work out the mean flow rate. Yes ... though the flow rate will vary depending on the level of water in the butt. A sophistication would be to put a flow meter inline, but I can probably measure the flow rate manually at different heights of the water butt level and estimate a reasonable value. Then as you say it should be straightforward to log the number of times the system opens the valve in any given time period; the length of watering cycle is fixed so it's just volume per watering cycle x number of cycles 🙂 1 Link to post
gldenwetgoose 21,497 Posted May 9, 2021 Author Share Posted May 9, 2021 Excellent - hopefully the sweat and tears over diagnosing the issue was a beneficial learning exercise too... at least in thinking about potential fault cases if nothing else. Well done. 1 Link to post
Kupar 13,341 Posted May 9, 2021 Share Posted May 9, 2021 8 minutes ago, gldenwetgoose said: Excellent - hopefully the sweat and tears over diagnosing the issue was a beneficial learning exercise too... at least in thinking about potential fault cases if nothing else. Well done. It was 🙂 (And thanks for the other suggestions; I'll order up a cheap Nano, use the 12V regulated supply for the Arduino too, and next time, remember to use the internal pullup resistor 🙂) 1 Link to post
Kupar 13,341 Posted June 6, 2021 Share Posted June 6, 2021 (edited) Just a quick update on the tomato irrigation system. Following advice from @gldenwetgoose I have replaced the Arduino Uno with a Nano Every (very much neater and more compact - I could fit it on the perf board) and dispensed with the separate controller 9V battery (using the 12V regulated supply that also powers the solenoid valve). I finally got round to testing those improvements, and it all still works. Calibration still to do (the tomatoes are growing nicely, but I am still watering manually at the moment). But that trial and error stage of the project will be fun and I have several weeks to get it sorted. Edited June 6, 2021 by Kupar 1 1 Link to post
MaxWasTaken 522 Posted June 9, 2021 Share Posted June 9, 2021 (edited) I have many nerdy hobbies but nothing to show for most of them right now. I am an avid gamemaster for role playing games tho. I build maps, tokens, handouts, weave a narrative, develop handy tools for my friends and do everything to enrich the experience. I attached a screenshot of one of my games to give an idea for what my art style looks like. I am no artist. I merely scour the internet for interesting images and create the threads i need to sticht them together. I will post again when i can show stuff from my other hobbies. Edited June 9, 2021 by MaxWasTaken Fixed capitalisation. Still annoyed with all the sentences starting with "I" but to lazy to rewrite xD. 1 1 1 Link to post
gldenwetgoose 21,497 Posted June 11, 2021 Author Share Posted June 11, 2021 Time to get the soldering iron out for a half-hour Friday afternoon project. This little fella ^^^ is a haptic motor, like you could find in a game controller. Cheap enough with eight of them for GBP6.50 or less from Amazon. They're small at 10mm diameter and just need a 3v dc supply for them to buzz quite happily. So for today's little plaything I got five pieces of some spare stiff wire to form a positionable 'skeleton' and one motor attached to each tip (they even have their own adhesive pad). Then a nice suede 'skin' to fit over it all. Hook it up to a 3v dc power supply and voila - an extra helping hand in the 'personal massage' department. (They do say small things amuse small minds - the proof of concept certainly seemed effective). For the future, if I decide to develop further I could switch the individual motors to pulse in turn or randomly I guess, but whether I bother doing that or not is a different matter. 2 2 Link to post
Kupar 13,341 Posted June 11, 2021 Share Posted June 11, 2021 3 hours ago, gldenwetgoose said: Time to get the soldering iron out for a half-hour Friday afternoon project. This little fella ^^^ is a haptic motor, like you could find in a game controller. Cheap enough with eight of them for GBP6.50 or less from Amazon. They're small at 10mm diameter and just need a 3v dc supply for them to buzz quite happily. So for today's little plaything I got five pieces of some spare stiff wire to form a positionable 'skeleton' and one motor attached to each tip (they even have their own adhesive pad). Then a nice suede 'skin' to fit over it all. Hook it up to a 3v dc power supply and voila - an extra helping hand in the 'personal massage' department. (They do say small things amuse small minds - the proof of concept certainly seemed effective). For the future, if I decide to develop further I could switch the individual motors to pulse in turn or randomly I guess, but whether I bother doing that or not is a different matter. You clever, naughty boy 😉. What does D think of this project?! 1 Link to post
Sophie 24,412 Posted June 12, 2021 Share Posted June 12, 2021 That's awesome! Really clever. This could be expanded for long distance relationships or something, if you had another glove with capacitive fingertips and Internet connectivity you could touch yourself and your partner would feel it through their glove. 2 Link to post
gldenwetgoose 21,497 Posted June 12, 2021 Author Share Posted June 12, 2021 21 minutes ago, Sophie said: That's awesome! Really clever. This could be expanded for long distance relationships or something, if you had another glove with capacitive fingertips and Internet connectivity you could touch yourself and your partner would feel it through their glove. Now that’s putting the ‘really clever’ into a simple idea. I did wonder about putting an element of randomness into the effect - but someone else controlling it would be so much more. 1 Link to post
Kupar 13,341 Posted September 7, 2021 Share Posted September 7, 2021 A question for my geeky, nerdy friends. If I want to build a cheap, functional real-time bat detector, I have two choices really: an analogue heterodyne detector that needs to be manually tuned to reduce the frequency of ultrasonic bat sounds to a human-audible level and, of course, works beautifully in real-time for listening to bats, but won't produce a digital file I can easily store and then visualise / analyse later a detector with A-D conversion, then using wither frequency division (or possibly time expansion) to create the audible sound and a file for analysis. Both will be best with the best wideband microphone / sensor I can find, but instinctively what do you reckon? I have a soft spot for analogue electronics, and am drawn to the simplicity and elegance of a heterodyne circuit approach, but am I being old fashioned? What would you do? Link to post
Paulypeeps 5,290 Posted September 7, 2021 Share Posted September 7, 2021 I would go with the digital:- Cheaper (less parts) Easier to get working (analogue is always a bit of a fiddle to get right, and will probably need constant tweaking) Can probably create a software filter to identify specific bats, or at least specific species. Can more easily filter out background noise. As you say you can post-process the data which could be interesting for temporal analysis of the data to graph activity against time. Yes, you are being a bit old fashioned, but I do know exactly how you feel. It is I think about entering the world of the unknown (digital) when the analogue world is known very well. 1 1 Link to post
Kupar 13,341 Posted September 7, 2021 Share Posted September 7, 2021 54 minutes ago, Paulypeeps said: I would go with the digital:- Cheaper (less parts) Easier to get working (analogue is always a bit of a fiddle to get right, and will probably need constant tweaking) Can probably create a software filter to identify specific bats, or at least specific species. Can more easily filter out background noise. As you say you can post-process the data which could be interesting for temporal analysis of the data to graph activity against time. Yes, you are being a bit old fashioned, but I do know exactly how you feel. It is I think about entering the world of the unknown (digital) when the analogue world is known very well. Thanks @Paulypeeps. Very helpful as ever 🙂. I'll let you know in due course how it goes. (Incidentally, the tomato watering system has been brilliant all summer 🙂.) Link to post
gldenwetgoose 21,497 Posted September 7, 2021 Author Share Posted September 7, 2021 Sounds a good plan - two points to remember…. You’ll need a microphone/ sensor which operates at the higher frequency of bat talk, higher than the normal 20Hz-20kHz spectrum. Also, if sampling digitally remember your sampler programme will need to capture at twice the highest frequency you’re working with - so if 40kHz is your upper cut-off you need to take 80,000 samples per second - or conversely a 12.5uSec programme loop time. May be challenging to do the sampling and analysis in real time. Edit note - looking at the ‘net and it seems bat talk goes from 40kHz - 100kHz…. So sampling up to 200kHz with a 16MHz processor could be a challenge? 2 1 Link to post
Kupar 13,341 Posted September 7, 2021 Share Posted September 7, 2021 2 hours ago, gldenwetgoose said: Sounds a good plan - two points to remember…. You’ll need a microphone/ sensor which operates at the higher frequency of bat talk, higher than the normal 20Hz-20kHz spectrum. Also, if sampling digitally remember your sampler programme will need to capture at twice the highest frequency you’re working with - so if 40kHz is your upper cut-off you need to take 80,000 samples per second - or conversely a 12.5uSec programme loop time. May be challenging to do the sampling and analysis in real time. Edit note - looking at the ‘net and it seems bat talk goes from 40kHz - 100kHz…. So sampling up to 200kHz with a 16MHz processor could be a challenge? Thanks 🙂. Not a straightforward thing then. I'll have a dig around before committing to anything. That's beginning to sound like expensive DSP. As ever, grateful for your expert knowledge ❤️ Link to post
Paulypeeps 5,290 Posted September 7, 2021 Share Posted September 7, 2021 There must be something in the PIC range that will be fast enough and only cost a £1. I think that the last one I played with can clock at 64MHz and has a built in 32MHz RC oscillator. 1 Link to post
Sexismygod 1,782 Posted September 16, 2021 Share Posted September 16, 2021 I thought about putting this in the Funny stuff thread but it's pretty geeky. Quite possibly a "funny if you were there" moment. This happened at a trade show many years ago when we got the 3D signaling controls backwards on a virtual reality system. The 3D looked horrible until someone figured out the rather easy fix (can you spot it?). Certainly better than stopping the presentation and re-configuring the system. 1 3 Link to post
IEnjoyPiss 189 Posted September 16, 2021 Share Posted September 16, 2021 1 minute ago, Sexismygod said: I thought about putting this in the Funny stuff thread but it's pretty geeky. Quite possibly a "funny if you were there" moment. This happened at a trade show many years ago when we got the 3D signaling controls backwards on a virtual reality system. The 3D looked horrible until someone figured out the rather easy fix (can you spot it?). Certainly better than stopping the presentation and re-configuring the system. Genus way of handling it Link to post
Kupar 13,341 Posted March 27, 2022 Share Posted March 27, 2022 (edited) Quick update on the bat detector thing (as K spotted a bat in the garden the other day and I realised I had been v poor about actually building anything, so now want something quick). And I am afraid I have wimped out somewhat and will be assembling a heterodyne detector from a kit (I know, I know). It's a long-established design and while I don't know the frequency response of the ultrasound sensor it uses, I figure that as it's successful in the UK market it must be able to cope with common UK bat species (the most common species - for PeeFans the rather wonderfully named pipistrelle - clicks at around 48kHz). Here are the circuit diagram and parts list for those interested. Incidentally, for the digital full-spectrum approach, this looks interesting (if you didn't want to design and build your own): https://www.openacousticdevices.info/audiomoth And should I get hooked on bats, and want to record and analyse the waveforms, I promise to build a digital detector / recorder of my own. Edited March 27, 2022 by Kupar Link to post
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now