Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 91
  • Members: 0
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
All today's birthdays', congrats!
Download (31)
ScottH (37)


Next birthdays
11/02 Download (31)
11/02 ScottH (37)
11/03 Electroguy (94)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: General Science and Electronics
« Previous topic | Next topic »   

Microcontroller for frequency synthesis from MIDI?

Move Thread LAN_403
aonomus
Wed Apr 15 2009, 04:35PM Print
aonomus Registered Member #1497 Joined: Thu May 22 2008, 05:24AM
Location: Toronto, Ontario, Canada
Posts: 801
Clarification: This is for *polyphonic* MIDI

Last night I was playing around with some midi files, trying to understand how the data can be sent via serial to other devices, and was wondering if its at all reasonable to attempt to use a microcontroller to monitor one particular channel (or multiple if desired) and create the resultant square or sinewave audio signal, mainly for multi-channel tesla coil setups.

I don't know all too much about this subject, but the two areas I looked into would either result in:
1. Inverse fourier transform
2. Offload the signal synthesis to a DDS chip, and do frequency shift keying

I was originally looking at using an arduino (since its the only microcontroller I understand), however considering the large amount of data that can be present, I'm not sure if the arduino would be able to even read the midi data and program a DDS chip fast enough. Any uC/DDS and MIDI gurus out there have any thoughts?

The result of this whole endeavor would be essentially a interface that monitors certain midi channels, and then spits out the sinewave or squarewave for a tesla coil to play. It would be trivial to flip a few dip switches and assign a coil to all the low notes, high notes, etc. This would also be similar to Arcattack.

Edit: After talking with a few people on IRC, I might try to make this work on a ARM chip, with 60MIPS, there should be plenty of processing power to do frequency synthesis, and with 4 PWM outputs, it could very well work...

Below is just a random image I took at 4am. I routed the MIDI out from the program I using through MIDI Ox so I could look at just how much data there is...

Routing
Back to top
Steve Conner
Thu Apr 16 2009, 11:34AM
Steve Conner Registered Member #30 Joined: Fri Feb 03 2006, 10:52AM
Location: Glasgow, Scotland
Posts: 6706
If you only want simple pulses suitable for triggering Tesla coils, or sine waves, DDS is the way to go. You can do DDS in software, or use an external chip like the AD983x/5x series.

Synthesizing proper, bandlimited, musical-instrument-grade square and sawtooth waves, while technically still "DDS", is a whole other ballgame. The state-of-the-art algorithm for doing this is called Minblep. I can't quite remember what the name stands for, let alone how it works.

Finn and I did our musical tricks using an old Roland keyboard, the JX-8P, which is what you see me playing in that infamous Youtube clip. It's a hybrid digital/analog design that generates the note pitches digitally, and they can be found on the motherboard as square waves. We just tapped into those (using some OMG sekrit circuitry) and voila a ready-made 6 voice polyphonic Midi-to-Tesla converter. JX-8Ps are so cheap used (under $200) that it wasn't worth our while developing a converter of our own.
Back to top
Dalus
Thu Apr 16 2009, 11:48AM
Dalus Registered Member #639 Joined: Wed Apr 11 2007, 09:09PM
Location: The Netherlands, Herkenbosch
Posts: 512
Enough information to be found on Minblep Link2 I think I'm going to order some hardware and experiment with what works best smile I just need an uC to start with, already have a few lcd's rotary encoders and optical receivers and transmitters.

Reading midi dat shouldn't be that hard finding a way to generate polyphonic sound is a great deal harder. . .
Back to top
aonomus
Thu Apr 16 2009, 02:20PM
aonomus Registered Member #1497 Joined: Thu May 22 2008, 05:24AM
Location: Toronto, Ontario, Canada
Posts: 801
Having worked with MIDI before, its amazing how fast the data can 'pile up' or be simply ignored because its coming in too fast for the uC to read it all....

For myself, this project will probably be delayed a fair bit but I'm starting my research into this now, thanks for the tip though Steve

Edit:

Problem solved. Use MIDI-Ox to create a loopback interface, and then use Ableton Live and a 5.1 surround card to give 4 or 5 independent mono channels. The only hard part would be shielding everything properly for TC compatibility with optos....
Back to top
GeordieBoy
Thu Apr 23 2009, 01:38PM
GeordieBoy Registered Member #1232 Joined: Wed Jan 16 2008, 10:53PM
Location: Doon tha Toon!
Posts: 881
If you want to use a Microcontroller to make a stand-alone piece of hardware, the way forward is the DDS algorithm (phase accumulator) as Steve Conner said.

This algorithm lends itself well to simultaneous operation with other instances of the same algorithm (ie to implement multiple oscillators for polyphonic tone generation.) All you have to do is declare multiple phase accumulators and update them all each time the sample period has elapsed.

The input variable to the DDS algorithm is also proportional to the frequency you want out. So there are no complicated divisions necessary to calculate period lengths etc. The only calculations you have to do are from MIDI note number to frequency. This can be implemented in a short lookup table if you don't need to implement support for pitch-bend. You only need 12 entries in the lookup table for the 12 notes at semi-tone intervals that make up one octave. The pitches for subsequent octaves can easily be achieved by using binary shifts to double or halve the frequency.

Since the phase accumulator ramps from zero to some fixed value like 255 or 65535, it is easy to generate pulse-trains of particular duty-ratios by comparing the phase accumulator to a fixed value. The output state is set depending on whether the phase accumulator value is higher are lower than the "pulse width" value. You can obtain anything from square waves to narrow pulses for triggering a Tesla Coil with this method.

It is possible to run 8 oscillators simultaneously on a 30MHz PIC from Microchip using a hardware interrupt programmed to occur at the sampling rate of about 80kHz. There should be sufficient cycles left over outside the interrupt serive routine for the necessary comms routines, MIDI message handling, polyphonic voice allocation, and MIDI-to-pitch calculations.

This is adequate for a polyphonic tesla coil if that is what you want it for, or a rough synthesiser. The sound quality doesn't come close to "studio quality" though if you are wanting to build a decent DIY synth.

I hope this helps,

-Richie,
Back to top
Steve Ward
Mon Apr 27 2009, 06:02AM
Steve Ward Registered Member #146 Joined: Sun Feb 12 2006, 04:21AM
Location: Austin Tx
Posts: 1055
I did my last 12-note polyphony midi-to-tesla decoder with an atmega1281, 8bit 16MHz microcontroller, it wasnt that bad. It does pitch bend and interprets volume controls too without much computation required. And i did most of the pulse generation manually (interrupt driven) so i could have the 1 chip generate 12 square waves at once... its even better if you just have the hardware timer/counters available to do it all for you (no real CPU involvement once the "tone" is started).
Back to top
GeordieBoy
Tue Apr 28 2009, 12:21PM
GeordieBoy Registered Member #1232 Joined: Wed Jan 16 2008, 10:53PM
Location: Doon tha Toon!
Posts: 881
12-note polyphony?

You ran 12 Tesla coils from a MIDI file??? suprised That is quite impressive!

-Richie,
Back to top

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.