Top Octave Generator chips and dividers

Started by R.G., September 07, 2011, 12:34:08 AM

Previous topic - Next topic

R.G.

The top octave generator chip was a handy device back in the 70s. Feed in 2MHz, take out one frequency corresponding to each frequency of the highest octave of the even-tempered musical scale. Most early organs used these, then a string of dividers. Once you have the top octave, seven stages of division gets you eight full octaves of the musical scale as discrete outputs.

TOGs were a custom logic widget, and they went the way of the dodo.

However, we now have microprocessors, right? Alls you gots to do is program a uC to make the top octave, right? Not necessarily. The real time constraints make this very hard to do, even with today's blowtorch processors, because the differences between the frequencies matter, not the absolute frequencies so much, and the human ear picks out little frequency problems.

I was pondering this - don't ask!  :icon_biggrin: - and it occurred to me that even if I did succeed in getting a uC to make the top octave, I still needed 12 divider chips to get the divided octaves, one chip per note.

If instead, I used the insides of the uC to make ONE note of the top octave, I never get into the problems with real-time counting of multiple notes, and after that, dividers are just binary counting, which controllers do very quickly.  So instead of a top octave generator, you do a note generator. One chip, all of the Cs, the next all of the Dbs, the next all of the Ds, etc. You have to do twelve uCs, but you save twelve divider chips and one really really tricky programming problem in making the TOG, which you also don't need. The program inside each uC is different by exactly one constant, the divider from the clock to the top frequency.

A uC that will do this - I think - costs $1.29 in ones. We'll see.  :icon_biggrin:
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Earthscum

Why is it I get something wierd in my hands (tonight I brought home a Casio keyboard to fix the power jack) and you pop up some irrelevantly relevant post? Keys, synths... and I have a craptastic Casio in hand, lol. It's a Casio CT 360 that apparently uses Pulse Code Modulation. I really don't know if it's even close in comparison to what you are talking about... just thought it was ironic.  :icon_biggrin:
Give a man Fuzz, and he'll jam for a day... teach a man how to make a Fuzz and he'll never jam again!

http://www.facebook.com/Earthscum

toneman

RG,
this is an interesting approach:  a uC for each note.  THEN use dividors for octaves.
Actually, U could probably do ALL the octaves with the ONE uC!  U'd have the extra pins.
But, a uC for EACH note would be great if U were going to build a many-key (note) system.

long ago, I was able to duplicate the TOG that "old crow" did with an obsolete PIC (a "C" series).
I used a 16F84 at the time and was able to make it function with only machine code programming.
I was thinking of one uC for black notes and one uC for white notes.
this was to lessen the calculations needed for real time output even using a 20MHz xtal.
Never got around to doing anything with it..it was just a challenge to myself at the time.

Don't know where U would be going with this 1-uP-per-note idea??
roland has so much stuff with their synth-engines, that it seems pointless to try to duplicate.
EH's POG is a killer bank-4-the-buck approach if U don't want to go hexaphonic.
Behringer has a $40 pitchshifter that goes 2octaves UP and 2octaves DOWN!
What would be your application?
Just wondering.......
8)


  • SUPPORTER
TONE to the BONE says:  If youTHINK you got a GOOD deal:  you DID!

soggybag

There was a PAIA project from way back called the Chord EGG (Encephalo Gratification Generator). It used a TOG to generate several notes which it faded in and out at random while sweeping a mild band pass filter across the left and right channels. I had the bug to build this when I first started this DIY stuff. I found a TOG at an Organ repair place online. I printed a PNP and ironed it on a black copper board. In the end I never etched the size of the project was daunting.

I remember when I was looking for the the TOG chip, which was hard to find, I ran across some info on using a PIC as a replacement.

All of this had to have been ten years ago.

http://www.paia.com/talk/viewtopic.php?f=9&t=118
http://m.matrixsynth.com/2008/03/paia-oddity-3790-eeg.html

Gurner

If bringing a uC into the mix, why have it only generate the top octave? (as this method would still require a lot of 'dividing down' hw)

Why not just have the uC generate the actual required note itself? (no matter which octave) - the amount of polyphony required would then dictate the number of uCs needed.

amptramp

You could also do an electronic emulation of the Hammond tone wheel chain - use a top note generator and do a 185/196 division eleven times to get the top octave, then just use a divide by two chain for each note.  You can use a buttload of 74HC161's with some other logic.  It might not be the cheapest way, but it would be impressive.

R.G.

Quote from: toneman on September 07, 2011, 12:48:11 AM
Actually, U could probably do ALL the octaves with the ONE uC!  U'd have the extra pins.
Actually, that's what I meant but used too many words to say, here:
Quoteand after that, dividers are just binary counting, which controllers do very quickly.  So instead of a top octave generator, you do a note generator. One chip, all of the Cs, the next all of the Dbs, the next all of the Ds, etc. You have to do twelve uCs, but you save twelve divider chips
The real work of making a high accuracy note is done in the timing loop. After that, you use an eight-bit word incremented by one every timing loop, and put the word out on pins. The individual bits are exactly the same as the outputs from a divider chain - which is what they are.

One uC generates the top note and all the lower octaves as outputs on the other pins.

Quotelong ago, I was able to duplicate the TOG that "old crow" did with an obsolete PIC (a "C" series).
I used a 16F84 at the time and was able to make it function with only machine code programming.
I was thinking of one uC for black notes and one uC for white notes.
this was to lessen the calculations needed for real time output even using a 20MHz xtal.
Never got around to doing anything with it..it was just a challenge to myself at the time.
I liked that setup. Messed with the code a bit, but never did much with it either.
Quote
Don't know where U would be going with this 1-uP-per-note idea??
...
What would be your application?
If I told you, I'd have to kill you.
:icon_lol:



R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Gurner

#7
As it goes, I've been dabbling in DDS myself over the past fortnight....my initial gut feeling is that low end (8 bit MCUs) are only good for about 5khz (even clocked with an instruction clock of 8Mhz+)

Quote from: R.G. on September 07, 2011, 11:09:05 AM

The real work of making a high accuracy note is done in the timing loop. After that, you use an eight-bit word incremented by one every timing loop, and put the word out on pins. The individual bits are exactly the same as the outputs from a divider chain - which is what they are.


I'm figuring you mean 16 bit word - this yields an 'accumulator' with the maximum number of values of 65536.

Re resolution/granularity (or what we're worried about - accuracy), that's a function of 'sample frequency/accumulator', therefore assume a sample frequency of 40khz, you get 40,000/65536 or resolution to 0.61hz ...good, but not quite there.

To get more granularity (accuracy), we need to increase the accumulator (to say 24 bits) or decrease the sample frequency - I reckon the the former is the way to go but then you start getting into complicated coding on 8 bit MCUs!

R.G.

Quote from: Gurner on September 07, 2011, 11:32:04 AM
As it goes, I've been dabbling in DDS myself over the past fortnight....my initial gut feeling is that low end (8 bit MCUs) are only good for about 5khz (even clocked with an instruction clock of 8Mhz+)
You may be right, although I have seen applications that claim usable sines in the 100s of kHz for 8-bit devices in DDS.

I wasn't thinking of doing DDS. This is purely to turn out a square wave output at the required frequencies, and specifically at as close to the even tempered scale as possible with hard-locked timing. Once you generate all the possible even tempered scale notes, you can generate other waveforms from that, including by phase locking a sine-output VCO to it, by shift register techniques, other ways, if that's what you were trying to do.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Gurner

Quote from: R.G. on September 07, 2011, 11:41:55 AM

I wasn't thinking of doing DDS. This is purely to turn out a square wave output at the required frequencies, and specifically at as close to the even tempered scale as possible with hard-locked timing.

Aaah ok, IMHO you should be able to go much higher in frequency than 5khz (& with incredible accuracy)

R.G.

I think so. I was hoping to get the real top octave, between 10kHz and 20 kHz. The A in that octave is 14,080Hz, so the next frequencies are
- 14917.2
- 15804.3
- 16744
- 17739.7
- 18794.5
- 19912.1

Probably these aren't all that useful, because real human ears can't usually go up that high after age 20 or so. But hey, maybe someone.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Gurner

#11
So if you want a top frequency of 20khz, then I reckon a 40khz interrupt (sample) rate would be needed.

Assuming a 16 bit accumulator and a required frequency of 14.8khz...

14,800/40000 * 65536     means 24248 would be the amount you add to the accumulator every interrupt, which should yield a square wave of 14799.8046875Hz which in percentage terms is a miniscule error  

Using such a method, you lose the accuracy (in percentage terms) at the lower end of the audio frequency band, for example a required frequency of 50Hz...

50/40000 * 65536 = a value of 81 to be added to the accumulator which yields a frequency of 49.43Hz (i.e. about 1% error)

slacker

Someone did a one chip per note and then divide with CMOS over on the electro-music forums http://electro-music.com/forum/viewtopic.php?t=45583&start=0&postdays=0&postorder=asc&highlight=top+octave. His method of generating the notes was pretty neat. I don't know if there's anything in there that might be useful to doing it with uCs.

Gurner

Two oscillators per puC (PIC) here, and divided down...

http://picsynth.000space.com/schematic.html

...quite a neat implementation.

PRR

> a uC to make the top octave, I still needed 12 divider chips to get the divided octaves, one chip per note.

Any way you slice, it takes 50 to 100 output pins.

Since you only get 8 to 13 useful pins on compact packages, you need 4 to 12 chips. Maybe fewer larger chips, but even a 80286 CPU only had 68 pins. PIC16F8877A is 40 pins, unless my eyes crossed, and seems to be no-stock. Parallax SX comes up to 48 pins and 75MHz clock, but seems to be end-of-life.

There's a cascade divider, CD4040, which will take your high A and give all the lower As, for like 29 cents. Therefore it seems sweet to have your one special chip just do the 12 high-octave notes, and fan-out with 4040s. Which is how it was done.

It seems you want individual PICs for A A# B C C# D D# ... G#? Now you have twelve unique parts. All the same chip but 12 programs to maintain. Sure, they differ in only one byte (the divider), but any code changes must be copied to 11 more files with new revision number, you need 12 separate code-flashings, you need 12 bins and 12 little stickers so the right parts go in the bag and into the right socket.

Ah, you could use one code-base which at power-up examines its pins and becomes A A# B etc depending how socket pins are pulled up/down. So the note assignment is in the socket/PCB not the chip. It's still twelve $3 PICs at $36 instead of one $3 PIC and twelve $0.29 divider strings for $7.

Additional wish-list items (for someone else; I haven't touched a TO in decades):

The tuning is close, but not perfect equal-temper, and has become stereotypical of new-age synths/organs of the late 1970s. We need that sound, but perhaps also another with different error so it does not sound like all the others.

The minimum error is related to the 2MHz top rate, a compromise with cost of 1970s logic and low-volume production. A 20MHz clock could make errors inaudible.

Equal-temper is just an ugly thing. There's 9,876 other tunings (I saw a list somewhere), a few dozen which are better for some things (worse for others). One interesting tuning is to set the Thirds perfect (instead of ET's dissonance), to go along with overdriven amps and their Perfect Third distortions. Of course this means a higher level of user-interfacing than a simple TO chip needs.

A wild approach: you only got 10 fingers. Input the key-presses, derive _just_ those notes (with overtones), and output.
  • SUPPORTER

R.G.

Yeah, I've been through all those approaches many, many times. The top octave generator is the clear winner - but there doesn't seem to be any good way to do it with acceptable accuracy without really, really high speed uCs. 20MHz is probably minimum. It's a tough programming problem to run all 12 dividers in parallel and address the issue of latency to handle all the results. The time spent changing an output then calculating the next state of all 12 and getting an output updated when they may all change at once gets out of hand. Been there.

The only way I could think of to solve it without sheer brute force clock speed was to program all the adders in vertical counters so all bits changed (effectively) simultaneously.

However, using hardware to sidestep a programming problem seems justified, especially when it requires less raw speed than doing the difficult problem.

Quote from: PRR on September 09, 2011, 09:19:10 PM
Any way you slice, it takes 50 to 100 output pins.
Yep.

QuoteThere's a cascade divider, CD4040, which will take your high A and give all the lower As, for like 29 cents. Therefore it seems sweet to have your one special chip just do the 12 high-octave notes, and fan-out with 4040s. Which is how it was done.
Yep. Actually, I like the CD4024 for that job. It's a 7-stage, and is a little easier to find (or was last I looked) than the 4040, which is a 12 stage. It is a sweet idea to have one top chip and  12 dividers - if you can get that top chip. The top octave chip can be had for $35-$50 today.
Quote
It seems you want individual PICs for A A# B C C# D D# ... G#? Now you have twelve unique parts. All the same chip but 12 programs to maintain. Sure, they differ in only one byte (the divider), but any code changes must be copied to 11 more files with new revision number, you need 12 separate code-flashings, you need 12 bins and 12 little stickers so the right parts go in the bag and into the right socket.
Yep. That is what I was proposing as a sidestep to the unavailability of the TOG.

QuoteAh, you could use one code-base which at power-up examines its pins and becomes A A# B etc depending how socket pins are pulled up/down.
Yep.  :icon_biggrin:
I could also put programming pins on the board and make the one in the "A" socket be an "A".  :icon_biggrin:

QuoteIt's still twelve $3 PICs at $36 instead of one $3 PIC and twelve $0.29 divider strings for $7.
Now we're getting to the rub. The PIC I thought I'd use to do one note and divide it eight times with eight outputs is a $0.75 PIC, $1.29 in units at Mouser. Well *a* PIC that will do it. I didn't try to minimize total dollars; I was solving the tough real time programming problem.

But looking things up now, I find I can get a 20MHZ PIC 16F54 that would do the simple countdown and octaves for $0.66 in ones. I was going to use another one, but the F54 will do. That's 7.92 for logic. A 32MHz PIC that might do the top octave job is $1.48, which is much lower than two years ago when I first touched the problem. And CMOS is now going up in cost. Mouser wants $0.48 for a CD4024 and $0.52 for a CD4040. A PIC + dividers system is one high speed PIC and twelve dividers, for a total of 12* $0.50 + $1.48 = $7.48

They actually come in very nearly the same cost. I hadn't expected that.

QuoteThe tuning is close, but not perfect equal-temper, and has become stereotypical of new-age synths/organs of the late 1970s. We need that sound, but perhaps also another with different error so it does not sound like all the others.
I like the program-on-board approach. You can make the dividers be any temperament you like. Another PIC also lets you have it do the on-board programming of all the note PICs, and get any temperament you like.

QuoteThe minimum error is related to the 2MHz top rate, a compromise with cost of 1970s logic and low-volume production. A 20MHz clock could make errors inaudible.
It turns out that 2MHZ is OK for hard logic dividers doing equal temperament. It is much harder to do the job in a program instead of hard logic dividers. I have not finished the programming, obviously, but a 20MHZ PIC is likely to just barely able to generate the same top octave that a 2MHz hard logic divider TOG does.

I looked into gate arrays and FPGAs, but that's a mess.


R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

analogguru

#16
Don´t waste your time, this has already been done with a pic ages ago:
http://www.picbasic.co.uk/forum/showthread.php?t=11484&page=1
http://www.dutchforce.com/~eforum/index.php?s=5d02ddf66e923bb79f6379999837cd28&&act=ST&f=1&t=35897

And the CD4024 was used in several synths/organs as a divider (instead of the more expensive SAJ110).

analogguru

Taylor

Quote from: analogguru on September 10, 2011, 04:49:59 AM
Don´t waste your time, this has already been done with a pic ages ago:
http://www.picbasic.co.uk/forum/showthread.php?t=11484&page=1
http://www.dutchforce.com/~eforum/index.php?s=5d02ddf66e923bb79f6379999837cd28&&act=ST&f=1&t=35897

And the CD4024 was used in several synths/organs as a divider (instead of the more expensive SAJ110).

analogguru


But that program puts out middle C as its highest note, so about 6 octaves too low, right?  ??? But perhaps it will work for RG's mysterious app (I'll let some one else post the photo of the flower blooming  :icon_lol: ).

R.G.

Yep, I'm very familiar with that particular piece of code. It is done with a 16MHz PIC, and as Taylor notes, is several octaves too low to be a top octave. It also has some accuracy limitations.

I think I first saw that some years ago. The approach used in that code is to subdefine timer intervals which are counted to get to the note frequencies. The timer intervals are what get counted, and in turn are the limiting factor on either accuracy or the octave you generate, depending on your approach.

Getting to a real top octave requires a much faster processor. Four octaves up from that is really what you need for a top octave. Using that same code gets you to the nominal top octave at 64MHz for the PIC architecture. Other uC architectures with 1 instruction per clock cycle architectures may get the same performance at 16-20MHz, but also may not get you the reliable number of instructions per cycle of the PIC.

Thanks, but I've been there, and it helps define the problem, not the solution.

The approach of doing one note per PIC does two things: (1) it makes the programming simpler because you only have to count one interval and (2) it raises the frequency of the accurate note you can generate.

Quote from: Taylor on September 10, 2011, 07:13:53 AM
But that program puts out middle C as its highest note, so about 6 octaves too low, right?  ??? But perhaps it will work for RG's mysterious app (I'll let some one else post the photo of the flower blooming  :icon_lol: ).
My flower bloomed so long ago that it's already wilted.  :icon_biggrin: Besides, having been burned on the net a few times, if I were doing a start up, you wouldn't read about it here.  :icon_lol:
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

artifus

any guitar related suggestions for putting a tda1008 to good use?