Welcome to our forum. A Message To Our New and Prospective Members . Check out our Forum Rules. Lets keep this forum an enjoyable place to visit.

Check out our 2023 Group Christmas Project HERE

AAA
Avatar
Please consider registering
guest
sp_LogInOut Log Insp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSSsp_TopicIcon
Cabin Fever has set in.... BillyG
Topic Rating: 5 Topic Rating: 5 Topic Rating: 5 Topic Rating: 5 Topic Rating: 5 Topic Rating: 5 (2 votes) 
Avatar
BillyG
Brora, North-east Scotland
March 27, 2020 - 2:08 pm
Member Since: March 22, 2014
Forum Posts: 3744
sp_UserOfflineSmall Offline

For all of us who are in self-isolation or lockdown or whatever - here's a thread to post your crazy ideas....

Actually, best plan is to create your own breakroom topic with the same title, but your own forum nickname - I can foresee a LOT of craziness happening soon...

OK - so here's mine....

I enjoy programming and electronics in general.  I already have done stuff with small embedded systems like the Raspberry Pi - but I've always had a hankering to mess around with one of these tiny little micro-controllers ( the Atmel ones ).   I actually have a "real" project in mind for it - but that one is really trivial and boring, and has nothing whatsoever to do with music.

So anyway.... I got myself a "Pololu" A-Star ( based on the Atmel device ) microcontroller board - and the "real" project is already complete and done - however- I was tickled by the idea of rustling through my components box to see what was lying there - and I found a couple of light-dependent resistors.

The thought process went like this..... 

"Light dependent ??? - hmmmm  - interesting"

"Microcontroller board has several (I'd only need one of each) analog input pins and digital output pins..   ahaaaa"

"I could wire it up (and write some software for the controller board) to "look at" the resistance value of the LDR (which varies with the amount of light falling on it.....)  AND THEN - I could issue a simple pulse train at audio frequencies on one of the digital output pins,, depending on the value sen at the LDR...  ahaaaa - close to a Theremin, methinks"

LOLOL - 

OK, so, I may be daft but not stupid- using an LDR for this type of thing has huge issues due to the natural variation in the ambient lighting (and the wide variation in response between LDR devices, even of the same type - but that's not gonna stop me).  To do it "properly" I would really want to use two LDRs - one as a reference for the current ambient light level, and the second to be shaded from the light by waving a hand towards/around it as one would do with a real Theremin...   

A real Theremin would be much more stable - since it works on the variation of a locally generated electric field by effectively modifying the beat frequency between two oscillators dependent on (what I assume is) the capacitive loading around the aerial as a hand (or other item) varies its position relative to the aerial.  I imagine that yes, in real terms, such a Theremin will still have a "baseline" or reference frequency that may well vary dependent on some external conditions - perhaps such as humidity, closeness of the apparatus to other earthed or metal objects and so on - but - for any short time of playing - it would be pretty stable - unlike the potential short-term variation of background/ambient light in my plan....  but that's not important - I'm NOT trying to build a real Theremin - this is just a fun thing....

So - here are the components - (1) The micro-controller  (2) the LDR - and in essence that's all we'd really need - although - I will have to add a dropper resistor and a 3.5mm jack-socket to get the audio signal out onto a cable....

Microcontroller.JPGLDR.JPGImage Enlarger

LOL the image of the LDR is larger than the actual device....  anyways....

If anyone is interested - here are links to the devices in question

http://www.hobbytronics.co.uk/.....32u4-micro

https://uk.rs-online.com/web/p.....s/9146710/

I just know in advance that this is not going to be hugely stable  - but - I can easily make it more interesting and to some extent useable, if instead of having the true Theremin effect (the glissando-ing/sliding sound) I could do a version that just "locked in" to say, a 2 octave diatonic(or even better, pentatonic) scale...   hmmmm, pentatonic is a good idea...

Right - the plans have gelled.

I'll be writing a little bit (really little, actually, most of the code needed is already present in existing libraries) of code tonight - fingers crossed - video of results tomorrow!

D'Oh - then I'll have to find something else to do.....

sp_PlupAttachments Attachments

I seriously recommend not copying my mistakes. D'oh - guntohead.JPG

Please make your own, different mistakes, and help us all learn :-)

Avatar
Irv
Members

Regulars
March 27, 2020 - 3:45 pm
Member Since: December 23, 2017
Forum Posts: 1650
sp_UserOfflineSmall Offline

@BillyG and others.  I have been looking at YouTube videos regarding Dr. Forrest Bird.  He had a fascination with two aeronautical formula, and made a inventive career out of them.  He created the first ventilator (which supplanted the iron lung).  He also invented the g suit of World War II.  

He sadly only co-authored one book—on the process of inventing.  I have it in order.  

I also am examining a p&h viola bow from your side of the pond (I have a separate forum thread on that) that can be rehaired at home for the slim purchase of new hair for $7.  The only tool needed is the threaded button rod.  

Success is the progressive realisation of a worthy ideal. —Earl Nightingale.

Avatar
BillyG
Brora, North-east Scotland
March 28, 2020 - 2:07 pm
Member Since: March 22, 2014
Forum Posts: 3744
sp_UserOfflineSmall Offline

Heheheh @Irv - always got things to do - way to go !

OK - so - quick update on the daft Light-dependent-Theremin project - 

Basically - IT LIVES....  with all of the limitations I more or less expected...  I promised a vid today, and indeed I recorded some demos - but - circumstances had dictated that I moved the "test environment" into a light-controlled location ( that being my blinds-closed and darkened music room with a single, constant, ambient light level). 

Prior to that - I had just been testing it on the coffee-table in the lounge, but the ambient light-level was constantly changing as the sun came up, then clouds drift by, then bright again etc etc - just as I expected really - which made the constancy of "playing" close to impossible - but it works within my expected limitations !!  Cool !

Unfortunately, once moved to my music room - although I recorded some demo stuff - I hadn't noticed that the mic was real close to the laptop, and fan-noise pickup pretty much ruined the audio... my bad.....  I'll re-do it either later tonite or early tomorrow !

I seriously recommend not copying my mistakes. D'oh - guntohead.JPG

Please make your own, different mistakes, and help us all learn :-)

Avatar
BillyG
Brora, North-east Scotland
March 29, 2020 - 6:48 am
Member Since: March 22, 2014
Forum Posts: 3744
sp_UserOfflineSmall Offline

I make no apologies for this - none at all ROFL - 

feature=youtu.be

I seriously recommend not copying my mistakes. D'oh - guntohead.JPG

Please make your own, different mistakes, and help us all learn :-)

Avatar
Peter
West Sussex, England UK
Members

Regulars
March 29, 2020 - 7:44 am
Member Since: September 27, 2019
Forum Posts: 378
sp_UserOfflineSmall Offline

Sounds smooth, and I'm impressed with the pentatonic quantizing of the pitch. I'm guessing this is direct-synthesis rather than heterodyne.

I think your '220' is really 440 Hz; years of listening to 700 Hz sidetone and received code has given me a fair ear.

Peter

"It is vain to do with more that which can be done with less"  - William of Ockham

"A crown is merely a hat that lets the rain in" - Frederick the Great

Avatar
BillyG
Brora, North-east Scotland
March 29, 2020 - 8:08 am
Member Since: March 22, 2014
Forum Posts: 3744
sp_UserOfflineSmall Offline

Hmmm, that surprises me @Peter....   by any chance were you just listening on tinny laptop speakers and the low-end was "lost" - well - I doubt it.. LOL

I had to check - here's the low A from the active speaker as seen by a tuner app thing on the accursed so called smart-phone..

And the tone itself is generated by an "intrinsic" function from library code, picked from an array of values in my own code - 

To your guess - no - not heterodyne, and indeed, it's not so much "synthesized" (well, I suppose in essence it IS - but incredibly simply) - it will be implemented internally to the LSI device in the form of a programmable down-counter (which reloads on "zero count" or something similar, which just drives a digital (logic level) square-wave onto one of the output pins on the Atmel device

 

Code extract ----

#ifdef MAJOR_PENT
// only needed for major pentatonic mode operation
// A major pentatonic: A, B, C#, E, F#, A, B, C#, E, F#, A etc etc
int Notes[16] = {220, 247, 277, 330, 370, 440, 494, 554, 659, 740, 880, 988, 1108, 1318, 1480, 1760 }; // A-major pent frequencies
#endif

......

#if defined(MAJOR_PENT) || defined (MINOR_PENT)

// again, the power (0.5) empirically determined !
NoteNum = (int)( pow(LDR_Val, 0.5)) ;
if ( FTR ) {
// First time round - ENSURE the background illumination is on, and the sensor is facing it..
FTR = false ;
OffsetNote = NoteNum ;
}
else {
NoteNum -= OffsetNote ; // re-map note to start of array for the scale in use
if (NoteNum != PrevNote) {
PrevNote = NoteNum;
tone ( AudioPin, Notes[NoteNum] ) ;  <<< the call to the built-in "tone" function
TraceNote = true ;
}
}
delay ( 300 ) ;    // 200 bpm
//
// And, yep, that's it !
//
#endif

 

Picture-1.jpgImage Enlarger

sp_PlupAttachments Attachments

I seriously recommend not copying my mistakes. D'oh - guntohead.JPG

Please make your own, different mistakes, and help us all learn :-)

Avatar
ABitRusty
Members

Regulars
March 29, 2020 - 8:23 am
Member Since: February 10, 2019
Forum Posts: 3896
sp_UserOfflineSmall Offline

well alright!  nice @Billyg!  were you surprised by anything once you started putting it all together?  and what I mean..the capabilities turned out more..or you wanted to code a certain way and the chip wouldnt support it.  sounds smooth by the way.  

Avatar
BillyG
Brora, North-east Scotland
March 29, 2020 - 8:49 am
Member Since: March 22, 2014
Forum Posts: 3744
sp_UserOfflineSmall Offline

:) LOL @ABitRusty - cool !

Not surprised by anything really, all much as I expected.  The primary "issues" are related to the light sensor, and really as expected.  The LDR is a passive device, and changes its resistance from "around" 1KOhm under full direct daylight, to around a couple of MOhms in complete darkness.  It is highly non-linear (basically a log-law device) and it is extremely difficult to achieve "complete darkness" without some form of shielding/screening because the base of the device is just some form of plastic or epoxy which - if the are any photons bouncing around - which there usually are - will "leak through" even when the face of the sensor is truly blacked-out.   The LDR Theremin is virtually unusable in normal daylight (just due to natural daylight changes - so - in "Theremin mode" you'd just have to rely on your ear and continually adapt !!!!   Hence my move to a "controlled illumination" set-up !

These devices are notoriously variable in their response, so even with a spec, I knew I'd have to resort to some form of empirical testing to get "controllable" values for that one specific device I was using - find another (exact same, apparently) the "magic number" in the "pow" formula would have to be re-determined, and would be unique to that device.

A much better choice would be an active device, like a "proper" phototransistor - but I didn't have one in the odds-and-sods component box - and not worth getting, really.

There is only a VERY limited amount of memory on these microcontrollers - I mean we're talking  only 2560 BYTES ( not KBytes ! ) of RAM and 32KBytes of program space (flash memory).  EVERYTHING is pared back to the bone, and although it would have been nice to actually synthesise a voice, no, it wouldn't be possible, and, I just relied on one of the internal down-counters to drive a square wave to an IO pin.  Perfect !

Of course, although in the video you see the white USB cable (goes to the laptop where there is a development IDE for compilation and downloading) - once programmed, that connection is no longer needed, and a simply 9 to 15V battery on a couple of other pins gets it working - and I suppose - rather than feeding the audio (black cable) to an active speaker - sure - you could get away with one of these miniature "flat speakers" for a more or less self-contained device....  But, I don't need to go there...

Thanks for your interest !!!!

I seriously recommend not copying my mistakes. D'oh - guntohead.JPG

Please make your own, different mistakes, and help us all learn :-)

Avatar
ABitRusty
Members

Regulars
March 29, 2020 - 12:27 pm
Member Since: February 10, 2019
Forum Posts: 3896
sp_UserOfflineSmall Offline

@Billyg yes as you said and @Peter talked about memory.. the arduino has it on the board you would need external dram for extra large programs.  seems like that was the boring part in the make book I posted.  memory management.. I hear crickets..zzzzz.  :)   you probably have some type of ultrasonic device in your kit.  maybe a distance measurement type approach to make it less light sensitive.

Avatar
Bob
Members

Regulars
March 29, 2020 - 2:25 pm
Member Since: July 13, 2017
Forum Posts: 355
sp_UserOfflineSmall Offline
10sp_Permalink sp_Print
0

@BillyG FANTASTIC... .

 

Give yourself a hand....

Oh yeah, you already did :)

I guess I need to get some of these more modern processors. I've been stuck in the Microchip and TI MSP430 evaluation board world. 

Thanks for the fun.

Bob in Lone Oak, Texas

Avatar
BillyG
Brora, North-east Scotland
March 30, 2020 - 2:25 am
Member Since: March 22, 2014
Forum Posts: 3744
sp_UserOfflineSmall Offline
11sp_Permalink sp_Print
0

Bob said
.......Thanks for the fun.  

LOL, any time, any time !

Yeah, get yourself modernised there Bob !   j/k

The board I used is about the most minimal (and physically smallest)  version of the Arduino set of boards (so not all of the Atmel micro-controller IO pins are available, just a subset), and comes in at less than $10.  The development IDE environment is freely available, as are numerous base-line libraries for all the different boards.  All that's needed then for development is a USB cable (and, if you want, a prototyping breadboard as I used - but not essential for simple projects like this really) - not even an external PSU.

I love going back to basics - it reminds me in an odd way of the types of thing I did on my first hand-built-from-a-kit computer, the Acorn Atom.   It had all of 4Kb Ram with an inbuilt Basic interpreter in ROM - with a "Code" break out to write assembler when needed.   Oh happy days.......

Out of passing interest, since we're on the subject - someone (@Peter and or @ABitRusty) were wondering about the sound "synthesis".  Clearly the sound is just a square wave output - because there really is no space for any sort of extensive wave-tables / sound-font etc.   But, it has triggered another idea for this little board - audio (at a bandwidth of 4Khz or so) is just fine for speech ( telephony etc ) - and - I was just thinking about this overnight - I might just try to do a PWM ( as distinct from PCM ) encoding of a couple of violin audio samples and use THAT (the PWM encoded audio) to create a horribly basic synth on that board.   It *might*just be possible - I need to re-investigate PWM techniques, but certainly, such encoding is hugely more compact than our current day .wav, .mp3, .sf2 types of thing....

Oh well, keeps me busy if nothing else...

I seriously recommend not copying my mistakes. D'oh - guntohead.JPG

Please make your own, different mistakes, and help us all learn :-)

Avatar
Peter
West Sussex, England UK
Members

Regulars
March 30, 2020 - 4:05 am
Member Since: September 27, 2019
Forum Posts: 378
sp_UserOfflineSmall Offline
12sp_Permalink sp_Print
0

There are so many ways to generate an audio-frequency signal electronically and to control it with real-world physical phenomena. One method I tried which may be deserving of further inquiry is acoustic time-of-flight period control; an electronic interface into the world of acoustic resonance.

My setup for this was to use one of those cheap ultrasonic distance-measuring devices ( HC-SR04 - a favourite among Arduino enthusiasts) and to subvert the intended use by feeding back the output pulse to the HC-SR04's clock input. This, I hoped, would give a tone whose frequency was inversely proportional to the distance of the reflective surface (perhaps the 'player's' hand) and thus produce a theremin-type instrument. It worked, but suffered terribly from aliasing and so jumped around over a narrow band of frequencies. On reflection I should have paid more attention to signal processing: I used a mono to clean up the output pulse's falling edge before feeding back to the ultrasound generator, but something wasn't quite right. I got distracted before I could finish the debug.

I may return to this idea, or I may refine the 24 MHz theremin, or just get on with fiddlin'.

Peter

"It is vain to do with more that which can be done with less"  - William of Ockham

"A crown is merely a hat that lets the rain in" - Frederick the Great

Avatar
BillyG
Brora, North-east Scotland
March 30, 2020 - 4:35 am
Member Since: March 22, 2014
Forum Posts: 3744
sp_UserOfflineSmall Offline
13sp_Permalink sp_Print
5

Nice idea @Peter... yeah !

Me, well, I don't REALLY want a Theremin..... the darned fiddle is hard enough, LOL.  So, other than investigating PWM (just out of interest / refresher) - this is probably where it ends !

And yes, as you say, 

I may (... consider intermediate text deleted - couldn't find a text strike-through haha ...) just get on with fiddlin'.

  Yup, that's my plan !

I seriously recommend not copying my mistakes. D'oh - guntohead.JPG

Please make your own, different mistakes, and help us all learn :-)

Forum Timezone: America/New_York
Most Users Ever Online: 696
Currently Online: Gordon Shumway
Guest(s) 81
Currently Browsing this Page:
1 Guest(s)
Members Birthdays
sp_BirthdayIcon
Today RCall
Upcoming Sofia Leo, TKDennis, Ms-G, FiddleDetroit, CookiesViolin, Bobby, Elaisa, Michael Browder, EBurrell, Gordon Shumway, ViolinD, dougga, MoonShadows, Astandane, JohnG
Top Posters:
ELCBK: 7718
ABitRusty: 3896
Mad_Wed: 2849
Barry: 2690
Fiddlestix: 2647
Oliver: 2439
Gordon Shumway: 2422
DanielB: 2379
Mark: 2138
damfino: 2113
Member Stats:
Guest Posters: 3
Members: 31657
Moderators: 0
Admins: 7
Forum Stats:
Groups: 16
Forums: 81
Topics: 10581
Posts: 134093
Newest Members:
bittruster, fiddlecastro, jackdaniel, romanmills08, creativestringsinfo, rubble_b, mariachi, avagrey92, Alison, David
Administrators: Fiddlerman: 16429, KindaScratchy: 1760, coolpinkone: 4180, BillyG: 3744, MrsFiddlerman: 2, Jimmie Bjorling: 0, Mouse: 5296