PDA

View Full Version : CNC music



Evan
04-24-2008, 12:38 AM
I don't know if this should be labeled off topic or not.

I spent some time this afternoon doing a little finger cam. I calculated the proper feed rates to produce two octaves of the standard equally tempered scale that we use for western music by running the steppers at the right pulse rate. Then I did a little arranging. The music is a short clip from 76 Trombones by Meredith Wilson from The Music Man. I picked that tune because it was the very first piece of computer music that I ever heard on my Commodore PET back in '79.

Producing the right notes was the easy part. Getting the tempo close to correct is extremely difficult. Mach 3 is constantly trying to optimize the g-code on the fly. Worse, the note duration is dependent on the frequency of the note. The frequency is set by specifying a feed rate to three decimal places and that works just fine. The duration is set by specifying a distance to move and that is a pain because how long the move take depends on the feed rate which is different for each note. Also, the acceleration routine buggers things up differently depending on the feed rate.

I got it as close as I could until I decided it was good enough. The pie plate clamped to the end of the carriage is acting as a resonator to amplify the sound from the Y axis stepper. It's partly responsible for the crummy audio quality, the camera is also at fault. It sounds really cool in person. I sure wish the camera had an external mic jack.

This is a video file, 930kb long

http://www3.telus.net/metalshopborealis/76tbones.wmv

If you want to try it on your own CNC the g-code is here:

http://www3.telus.net/metalshopborealis/76tbones.txt

It should work ok on most any machine that is using Mach 3. It might work on others too but the tempo may be wrong. The notes should be alright since the mathematical relationship stays the same no matter what machine is used. It will depend on how audible your steppers are at low feed rates. Watch the creep toward the negative on the Y axis. Part of optimizing the tempo required arbitrary +/- feeds to get the right tempo, as much as is possible.

You can transpose the music by overriding the feed rate

S_J_H
04-24-2008, 08:13 AM
Evan,
That's actually pretty neat to see and hear. I'll give your code a try on my machines later. I think my kids will get a kick out of it.

Steve

Dawai
04-24-2008, 08:28 AM
JUST WHAT KINDA DRUGS ARE YOU ON?

Gee.. I remember a heroin addict laying his head on his guitar as he strummed. Swore it was talking to him.

Evan
04-24-2008, 08:31 AM
If you have already downloaded the g-code you should do it again. I improved the timing during the night.

I should mention that the g4 code is set to milliseconds in Mach 3.

Mcgyver
04-24-2008, 08:35 AM
that is too funny, way to go.

like David says, those must be some good drugs

Evan
04-24-2008, 08:39 AM
Gee.. I remember a heroin addict laying his head on his guitar as he strummed. Swore it was talking to him.

That might also be possible but not with a step and dir controller. :D

Dawai
04-24-2008, 09:06 AM
Evan:

Everyone here knows how smart you are.. the things you do are amazing most the time. THINGS like this? they are fun? Too much wasted time to me.

If you need directions and puzzles to solve? I got a whole book case of sketches and notes on projects. Some are good, some are bad. I will not live long enough to accomplish most of them.

Just lil things like that Hydrogen peroxide injected diesel engine? why has that not hit the market yet? Hydrogen peroxide powered boiler on a auto? could be the size of a lunchbox running A triple expansion steam engine, not been improved upon since the 1900's. I will never complete any of that. To save time, a rabbit with diesel engine would make a good block to start with.

You are good for so much more, your health improvement is natures way of allowing you to help others.

(okay enough bitching and nagging) get to work.

Ken_Shea
04-24-2008, 09:54 AM
I don't know if this should be labeled off topic or not.
Doesn't make any difference Evan, just post something, anything, and one of us here will take exception to it :D

That was very fun to watch, got a kick out of it.

Evan
04-24-2008, 10:00 AM
There is a practical side to this little project David. Stepper resonances can be a real problem. I have noticed when tuning the motors that if they sound out of tune to me they don't work as well and are prone to lockups when warm. My plan with programming the machine to the notes of the scale is to find harmonies that exist for the greatest number of combinations of X and Y interpolations. Tuning the motors to exactly the same frequencies isn't necessarily a good idea since that means they both share the same fundamental resonance frequency on common moves which can result in some nasty sounding beats. When doing linear interpolation on a G0 move the slower motor regulates the faster motor via the software so they both finish at the same time. Picking a frequency in terms of maximum feed rate that harmonizes with the other motor will reduce the number of moves that produce dissonant beat modes.

The musical scale provides a large number of possible choices. The scale is calculated by taking a frequency and multiplying it by the 12th root of 2. That is 1.05946309...
Each note on the 12 tone equally tempered scale is offset from either neighbour by that amount. If I program the motors to a particular key then I find that they sound more harmonious in operation. If nothing else I like it better.

loose nut
04-24-2008, 10:53 AM
Evan, you really need to get a hobby!

Evan
04-24-2008, 11:09 AM
Any suggestions??? :D

Dawai
04-24-2008, 11:17 AM
THE BIG arsed steppers on the bridgeport would be bass?

I slowed it way down.. I really don't need a 120ipm move with a g00 code.

Mine is sick. I keep patting it, but faith healing has not worked. Bent spindle still. It still drills holes.. but not very well anymore.

S_J_H
04-24-2008, 06:03 PM
I tried it out on my mill. Works (err...sounds great!).
I played it for my 19 year old son and his girlfriend. I am pretty sure they now think I am nuts,lol. :D

Steve

aboard_epsilon
04-24-2008, 06:17 PM
will it do... god save the queen

http://www.youtube.com/watch?v=7XR7OpM2Ufk

all these projects Evan ...and you haven't come up with anything to help the fuel crises ...
or free energy, is what you should be putting that brain to use on .

bet yah would have it licked in a month .

then you will really see people singing your praises .

all the best.mark

Evan
04-24-2008, 07:31 PM
I like a challenge. It occurred to me that it would be really cool if I could program the machine to play a piece of music while it was engraving the same music.

Along the same lines can g-code be used to engrave the same g-code that is doing the engraving? Never mind if there is a one to one correspondence as long as it is producing the same g-code in the same sequence that is running.