6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 5:47 pm

All times are UTC




Post new topic Reply to topic  [ 65 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
PostPosted: Thu May 24, 2018 1:56 am 
Offline

Joined: Wed May 23, 2018 9:00 pm
Posts: 9
Hi all,

I hope this doesn’t sound silly, but I was wondering if I could get some general guidance on how to approach a project I have in mind. I’ve been playing around with 6502 assembly off and on for a while now, mostly through the wealth of info in the NES homebrew games scene. I’ve begun to wonder if I could use a 6502 as a sort of controller for a DIY synthesizer in the same way that the 6502 at the heart of the NES interacts with the system’s Audio Processing Unit. As a musician and programmer, I’m fairly familiar with the the basic concepts behind audio synthesis, but my actual electronics knowledge is pretty scant. I’ve soldered together guitar pedal kits, but that’s about it.

It strikes me that a fun, long-term project would be a 3 voiced synth (oscillators, envelopes, and hopefully a filter or two) which seems doable if I don’t try to get too creative :wink: . The thing I’m struggling to conceptualize is then incorporating the 6502 as a sort of interface to the synth, reading “scores” (basic writes to audio memory) from some easily swappable and externally programmable memory.

If this all sounds super general, it’s because I still have only a vague notion of what exactly is possible. I’m familiar with Garth Wilson’s great primer on building 6502-based machines, but I’m definitely going to need to brush up on the basics before I get anywhere near the actual computer parts. What I would like to know though is if (1) anyone has made a project like this before (2) whether it’s plausible to do this a hobbyist, (3) general advice on where to start from the ground up.


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 2:37 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Without using synthesizer chips of any kind, you could use just D/A converters and direct digital synthesis (DDS) and a look-up table for each desired waveform, and use a non-maskable timer interrupt from a VIA for sampling.  See https://en.wikipedia.org/wiki/Numerical ... oscillator .  Many waveforms could be combined in software before they're fed to a D/A converter; but if you want to control the volume of each of them separately, it will be easiest if they're each given their own D/A followed by a digital pot, or just make the D/A a multiplying type.  Then of course you can combine them after that.  Putting the sampling on the NMI from a VIA timer will minimize the jitter as well as leave plenty of processing time for the other things you want to do like interpreting data and preparing samples to feed to the D/A(s) at the next sample time.

I have not been very active on the forum recently because I've had so much work (my work goes in waves) but I have a couple of D/A converter portions in the circuit potpourri page of my 6502 primer which you referenced.  If you have questions, I'll try to answer them quickly.  I've done this kind of thing many times with audio, just not really synthesizing actual music.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 3:22 am 
Offline

Joined: Wed May 23, 2018 9:00 pm
Posts: 9
Thanks so much for the quick and helpful reply! I’ll be sure to check out the circuit potpourri section you mentioned. I hadn’t thought of using digital synthesis and NCO’s, I guess because thought it was too labor intensive for a 6502-based system. It looks like I have even more to learn than I thought!


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 3:47 am 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
As far as easily-removable storage goes, you could use an SPI-10 module with a flash chip or EEPROM on it. The big problem with that is that getting the file onto those from a modern PC isn't all that easy.
You could use an SD card. Those could be a little annoying on the 6502 side, but I know it has been done, so it's definitely possible.
The other option I can think of is to use a CH376 module on the 6502 side to make use of USB sticks. I can't think of any reason it shouldn't work, but the datasheets are... of the quality I'd expect from a Chinese manufacturer.


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 3:50 am 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
Welcome, cynlic :)

you have different options, depending what challenges interest you, and what you hope to learn. You could have your computer "build" the audio one sample at a time (using a DAC as Garth said), or the computer could feed parameters to some sort of sound synth IC like that in the NES. Running your own DAC's will give you a real education, but it'll take longer before you're making sounds that resemble music. Using a synth IC gives you a big head start, but maybe it's like that old saying: It's the journey, not the destination!

BTW there are other musicians here, including Garth and me. Also, I just did a search and found 49 mentions of 2A03 on the 6502.org forum...

cheers
Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 4:35 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
cynlic wrote:
Thanks so much for the quick and helpful reply! I’ll be sure to check out the circuit potpourri section you mentioned. I hadn’t thought of using digital synthesis and NCO’s, I guess because thought it was too labor intensive for a 6502-based system. It looks like I have even more to learn than I thought!

I've used my 5MHz 65c02 workbench computer to sample at over 100,000 times per second, controlled by VIA timer interrupts—although for audio, regardless of the precision of the D/A, the jitter limits the effective precision to six bits at about 4kHz audio, whether you sample at 12kSPS, 24kSPS, 48kSPS, etc., and fewer bits as the audio frequency increases. Obviously if I were running at 20MHz, the six-bit accuracy would move from 4kHz to 16kHz.  The circuit potpourri page addresses jitter.  From one sample to the next, for DDS, all you have to do for most of them is add the increment value.  You will have loads of samples between times that you have to look up a new increment value, and the timing for those is not critical, as long as it's ready when it's needed.  This gets done in the background, when you're not in an interrupt-service routine (ISR).

You may need multitasking, like to handle the music while still watching the keyboard, feeding a display, etc..  There are easy ways to do this without a multitasking OS, and I cover this in my article at http://wilsonminesco.com/multitask/ .  I designed and programmed a semi-medical device a few years ago that did this, generating three audio signals while scanning and debouncing the keyboard and taking commands from it, timing things that would come due, feeding the display, logging results, etc., and these did not interfere with the signal generation.

Quote:
BTW there are other musicians here, including Garth and me.

I'm a cellist, and Jeff plays the bass viol.  (We play other things as well to a lesser extent.)  BDD plays the bass too.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 6:43 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8509
Location: Midwestern USA
GARTHWILSON wrote:
Dr Jefyll wrote:
BTW there are other musicians here, including Garth and me.

I'm a cellist, and Jeff plays the bass viol. (We play other things as well to a lesser extent.) BDD plays the bass too.

Garth, did you just say that Jeff's bass playing is...er...vile? :D :) :roll: :shock:

Attachment:
File comment: Everyone starts to talk during a bass solo!
bass_solo.jpg
bass_solo.jpg [ 102.29 KiB | Viewed 9887 times ]

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 6:49 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
I'm not a bassist, but I wanted to make the distinction between the bass in the violin family and the bass in the guitar family.  Do you prefer a different word?  I definitely have noticed that in jazz, the musicians talk during bass solos.  Major Healy in I Dream of Jeanie played the bass quite well.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 7:22 am 
Offline
User avatar

Joined: Fri Nov 09, 2012 5:54 pm
Posts: 1431
Welcome, cynlic.
Noticed this thread a bit late, sorry for "disrupting the concert" here. :)

cynlic wrote:
It strikes me that a fun, long-term project would be a 3 voiced synth (oscillators, envelopes, and hopefully a filter or two) which seems doable if I don’t try to get too creative :wink:

Hmm... reminds me to the 6581 SID, famous\infamous sound chip from the Commodore C64.

An impressive synthesizer project built with 8 SID chips would be the MIDIbox SID V2...
but it uses four PIC18F4685 microcontrollers instead of a 6502 CPU.
BTW: I'm not sure about price and availability of SID chips nowaday...

Some time ago we had a dissection of the SID chip in the forum.
But be warned, that this thread maybe goes a bit too deep into the inner details of the chip for your taste, and it's a lot of text.

Garth really has some nice and useful stuff on his homepage.
If you are out to build a simple 6502 based single board computer, also please take a look at Daryl Rictor's SBC-2.


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 9:21 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Welcome cynlic! I'm sure there's an interesting project to be done. Personally, I'd distinguish the one case where a 6502 controls some musical gadget, and the case where the 6502 produces waveforms directly. I think the second case is much more challenging, to say the least.

As I understand it, the SID chip was a revolution because it was designed by a musician for musicality - previous chips were more the descendants of sound effects chips, and don't hit the right notes. You might look into the OPL and OPL3 chips, as perhaps being more obtainable than SID. There's a rather technical thread over here which might provide some pointers:
http://stardot.org.uk/forums/viewtopic.php?f=3&t=11434

You also might be interested in the Music 5000 thread here:
viewtopic.php?f=4&t=4436

If you made up a conventional analogue synth then you could control that using a 6502, but you would need to master the digital-to-analogue conversions, as well as the tight timing control of the inputs.

Good luck!


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 11:46 am 
Offline
User avatar

Joined: Fri Nov 09, 2012 5:54 pm
Posts: 1431
Speaking of numerically controlled oscillators, the AD9834 DDS chip (Analog Devices) might be worth a look,
but for drum\noise effects, modulation etc. one might want to add a PRBS register similar like in the SID,
and envelope control would have to be done by software with a DAC or such.

AD9834 has SPI, but since one won't have to read the registers of that chip for generating waveforms, maybe SPI could be done with a 6522 shift register.

Hint: if you address decoding allowes you to write more than one DDS chip per SPI transfer, synchronizing the output of some DDS chips would be more easy.

;...

Analog Devices Application Note AN322 describes a bit how to use DACs as "potentiometers"
for setting the frequency of an analog sine wave generator.

For AppNotes on how to use DACs for controlling analog filters, see here in the SID thread.

;...

LM13700 dual transconductance OpAmp looks interesting for building analog filters etc.

;...

Long time ago there were analog function generator ICs like ICL8038, MAX038, XR2206 etc., but it appears that they all are out of production now.
The voltage controlled oscillator in the 4046 PLL chip only would give you a square wave...


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 12:29 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1250
Location: Soddy-Daisy, TN USA
Yet another option. Using pure 6502/DAC's is a great way (as other have said). But another option would be to use a Parallax Propeller micro-controller as your synthesizer and have the 65C02 send commands to it directly. You won't be able to run really fast (1 MHz) but that is fine. That should be plenty fast.

The Propeller runs at 3V3 but you can also run the 65C02 at 3V3 and you won't have to worry about any level converters.

The reason I mention the Propeller is because it has AMAZING libraries out that that emulate the SID, AY-3-8910, SN76489 and lots of other synthesizers. Plus, it can run several at a time. It has 8 cores (called COGS). You would need 1-2 COGS to interface with the 65C02. But that would leave around 6 COGS for synthesizers. Imagine 6 SID chips with 3 voices each!

_________________
Cat; the other white meat.


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 6:30 pm 
Offline

Joined: Thu Jan 21, 2016 7:33 pm
Posts: 282
Location: Placerville, CA
Wait, wait, people started talking synthesizers and nobody told me!? ;)

I think the key here is, you really ought to figure out what kind of synthesizer you're trying to build and then worry about how to drive it from the 6502 after that. If you're looking at an analog synthesizer, you'll need a DAC with reasonable resolution to produce the various control voltages (8-bit is too coarse for accurate pitch CVs; 16-bit is entirely adequate, and readily available these days) and some kind of sample-and-hold so that you can multiplex the single DAC between all the different CVs necessary (I know different vintage synthesizers had ICs that were something like 32-channel sample-and-hold devices; I don't know if anybody makes these anymore.)

If, on the other hand, you're trying to do a digital hardware synthesizer (or, as cbmeeks suggests, use a separate microcontroller as a "hardware" synthesizer,) all the 6502 really needs to do is stuff the correct values in the registers presented by the hardware and let it take care of the rest.

You could also employ a hybrid approach and use digital oscillators and an analog filter, which a few different synthesizers (PPG Wave, Korg DW-8000, Ensoniq SQ-80) did - this cuts down significantly on the number of CV channels you'd need and you could probably get away with using an 8-bit DAC instead (unless you want fine-grained control of the filter cutoff for things like key tracking.)


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 7:06 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
More a question of whether the 6502 has enough bandwidth to do adequate processing, or, perhaps, at what clock rate does the 6502 have enough bandwidth, especially if you start adding more channels and voices. There can be quite a bit of math involved, and it's very time sensitive.

The early computers had supplementary sound chips for a reason.

This is how the original Mac did it:
Quote:
The sampled sound engine piggybacked on the video circuit. As the raster scan returned from the right side of the screen to the left, one byte of data was placed into a PWM generator instead of the screen. This provided 8-bit sampled monaural sound sampled at the 22.25 kHz horizontal blanking rate.

Isn't that clever. Sampled sound "for free".

It was one of the early machines that was noted for sampled sound.


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2018 8:37 pm 
Offline

Joined: Wed May 23, 2018 9:00 pm
Posts: 9
Wow y’all, this thread has already become a wealth of information and ideas! Thanks so much.
I’m going to have to take some time to suss out the best solution for me out of all of those posted. I’d love to go the DDS route that Garth suggested because it seems like such an extensive learning opportunity…but with so much learning there will inevitably come many mistakes. I need to find a solution that is just frustrating enough to be fun :D. I also quite like the idea of using a dedicated IC at first like the OPL-3, but I know nothing about that particular chip other than how awesome it sounds. Plenty of research ahead!

Dr Jefyll wrote:
Also, I just did a search and found 49 mentions of 2A03 on the 6502.org forum...

Gah! I didn’t think of searching the 2A03 by name!

GARTHWILSON wrote:
I’m a cellist, and Jeff plays the bass viol. (We play other things as well to a lesser extent.) BDD plays the bass too.

Ha, I also play the bass to some extent (mostly jazz). I’m mainly a guitarist, and I spend too much time trying to find ways to compose noisy computer music… Hence how I dreamed up this project in the first place.

ttlworks wrote:
Hmm... reminds me to the 6581 SID, famous\infamous sound chip from the Commodore C64.

I more or less thought up the idea as a simplified/discrete SID. The originals seem to be kind of rare these days, and I don’t really fancy the idea of someone ripping a SID out of a potentially usable C64 just to feed my need for a fun musical project :).


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 65 posts ]  Go to page 1, 2, 3, 4, 5  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 59 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: