Edit: ah, Garth beat me to the punch.
Basic Project Advice for 6502-based Synthesizer?
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
cynlic wrote:
I wonder, would the bit depth of the sampletable be any kind of limiting factor?
Edit: ah, Garth beat me to the punch.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
The maximum S/N ratio you can get with a perfect 8-bit converter and no jitter is 50dB (from 8bits * 6.02dB + 1.76dB). (That's while there's signal. With no signal, the converter's output remains constant, with no noise at all if the reference voltage is quiet; so it's not like cassettes which gave tape hiss between songs.) [That's from the 6502 primer, in the circuit potpourri page's section on jitter. There's quite a lot of additional related information there too, so I won't repeat it all here.]
If volume reduction comes externally from a multiplying DAC or digital pot, the S/N ratio won't really suffer when you go below full volume.
If volume reduction comes externally from a multiplying DAC or digital pot, the S/N ratio won't really suffer when you go below full volume.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
- BigDumbDinosaur
- Posts: 9425
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
BigEd wrote:
In the head post, it looks to me like the project idea is a microprocessor controlled (analogue?) synth:
In which case the 6502 needs to set up each note and update according to the envelope: it's not running at waveform speeds.
Quote:
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.
Despite the complexity of what it was doing, Commodore's SID was controllable with relatively simple software. The amount of MPU time required to do so was very small relative to the total available MPU time. Despite the C-64's slow 1 MHz clock, music synthesis negligibly affected its performance, even in fast "shoot-em-up" games.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Basic Project Advice for 6502-based Synthesizer?
Not to mention the music it can play to accompany gnarly demo FX:
https://www.youtube.com/watch?v=ZazU4H2OZFg
https://www.youtube.com/watch?v=470On9iqPXc
https://www.youtube.com/watch?v=W-Crwct7U0c
For this reason, I consider the C64 a prime example of why the 6502 should primarily be a supervisor of specialised hardware, rather than trying to brute-force it in software.
https://www.youtube.com/watch?v=ZazU4H2OZFg
https://www.youtube.com/watch?v=470On9iqPXc
https://www.youtube.com/watch?v=W-Crwct7U0c
For this reason, I consider the C64 a prime example of why the 6502 should primarily be a supervisor of specialised hardware, rather than trying to brute-force it in software.
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
It's certainly hard to argue with the results.
Personally, I consider software synthesis to be best applied as a testing ground for ideas before they're migrated to hardware.
(And I just know someone is gonna fire back that they consider hardware synthesis to be best applied as a prototype stage for eventual software implementation...)
Personally, I consider software synthesis to be best applied as a testing ground for ideas before they're migrated to hardware.
(And I just know someone is gonna fire back that they consider hardware synthesis to be best applied as a prototype stage for eventual software implementation...)
-
DerTrueForce
- Posts: 483
- Joined: 04 Jun 2016
- Location: Australia
Re: Basic Project Advice for 6502-based Synthesizer?
I think software hitting its limits can be an indicator of where it could benefit from hardware acceleration. It certainly makes much more sense to me to do it in software first, where it's not as expensive, and then implement it later, if necessary or desired.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
Chromatix wrote:
For this reason, I consider the C64 a prime example of why the 6502 should primarily be a supervisor of specialised hardware, rather than trying to brute-force it in software.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Basic Project Advice for 6502-based Synthesizer?
Well, if you *think* you can do it in software, then by all means write the code, count the cycles, suck it and see. It'll be a tradeoff between hardware cost and software cost.
But I do have to ask the question: how will you run your user interface in between producing samples?
But I do have to ask the question: how will you run your user interface in between producing samples?
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
Chromatix wrote:
Well, if you *think* you can do it in software, then by all means write the code, count the cycles, suck it and see. It'll be a tradeoff between hardware cost and software cost.
But I do have to ask the question: how will you run your user interface in between producing samples?
But I do have to ask the question: how will you run your user interface in between producing samples?
As I said earlier, I designed a semi-medical device several years ago in my job which, although did not do music, did generate three separate, clean sine-wave outputs up to about 12kHz (frequencies set by the doctor), simultaneously, two of them modulated by a square wave (with the rate set by the doctor), while also scanning and debouncing a keyboard and taking commands from it, logging the effects on the patient, and other functions, and none of these produced any hiccups in the audio generation. The amplitude was changed only at zero crossings (taken care of by the ISR) so there was no spike produced there either.
This was all in software, on a 20MHz PIC16 (not even PIC16F1) microcontroller which does just under 5MIPS which is approximately the same number of MIPS as a 20MHz 65c02 except that the '02 has a better instruction set so it actually has hotter performance at a given clock rate. The doctor we did it for was pleased. For cooperative multitasking, I used the cyclic-executive method I describe in my '02-oriented multitasking article at http://wilsonminesco.com/multitask/ . My article on 65c02 interrupts is at http://wilsonminesco.com/6502interrupts/ .
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Basic Project Advice for 6502-based Synthesizer?
Lots of interesting stuff here, y'all.
I would say that BDD and Chromatix's suggestion that the 6502 be used more as a source of control values for an independent IC or circuitry, not synthesis, seems simpler to implement for a beginner like myself. I think once I get the basics of digital electronics (hell, even just basic electronics…) down, all of the suggestions here will be quite instructive, and I'll be able to tackle more CPU-intensive solutions. I’ve always had the unhelpful urge to jump into the deep end before I'm ready, which I'm trying to control at the moment.
That being said, I do have a quick question or two about Chromatix’s proposed sample-oscillator design.
1. Do I have it right that because you’re only using the, say, the higher 8 bits of a 16 bit counter, increasing the value by which the counter increments is more precise/granular because the upper bits will be flipped slower than if it were an 8 bit counter?
2. Is there a way to ensure that wrapping over the sample table will happen at zero-crossings in hardware? Obviously if you did this you wouldn’t be able to represent completely arbitrary waveforms, but it might be nice to have at least some kind of mode that does this so that modifying the sample memory during playback won’t risk gnarly clicking.
I would say that BDD and Chromatix's suggestion that the 6502 be used more as a source of control values for an independent IC or circuitry, not synthesis, seems simpler to implement for a beginner like myself. I think once I get the basics of digital electronics (hell, even just basic electronics…) down, all of the suggestions here will be quite instructive, and I'll be able to tackle more CPU-intensive solutions. I’ve always had the unhelpful urge to jump into the deep end before I'm ready, which I'm trying to control at the moment.
That being said, I do have a quick question or two about Chromatix’s proposed sample-oscillator design.
Chromatix wrote:
The next option is to do DDS using a largish RAM chip and a free-running counter, in which you can adjust the value added per cycle, the wrap address and the wrap decrement under CPU control. The counter should have more bits than the RAM chip has address lines, and you just use the high-order ones (for better frequency precision).
2. Is there a way to ensure that wrapping over the sample table will happen at zero-crossings in hardware? Obviously if you did this you wouldn’t be able to represent completely arbitrary waveforms, but it might be nice to have at least some kind of mode that does this so that modifying the sample memory during playback won’t risk gnarly clicking.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
cynlic wrote:
1. Do I have it right that because you’re only using the, say, the higher 8 bits of a 16 bit counter, increasing the value by which the counter increments is more precise/granular because the upper bits will be flipped slower than if it were an 8 bit counter?
Quote:
2. Is there a way to ensure that wrapping over the sample table will happen at zero-crossings in hardware? Obviously if you did this you wouldn’t be able to represent completely arbitrary waveforms, but it might be nice to have at least some kind of mode that does this so that modifying the sample memory during playback won’t risk gnarly clicking.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Basic Project Advice for 6502-based Synthesizer?
Yup, that's basically what I had in mind. If you build your counter so that it can wrap from and to arbitrary addresses, you can choose the location and length of your sample freely, and make sure *yourself* that it wraps at a zero-crossing.
Though what I'd do is to index over 64K addresses using a 20-bit counter, giving you 4 "fractional" bits. The increment value can be an offset 16 bits (so you now have 64K possible frequencies covering 16 octaves, depending on your sample length), while the start and wrap addresses can be 16 bits without offset. You can also try to use the wavetable RAM as a circular buffer for continuous playback; you'll need to be able to read back the upper 8 or 16 bits of the counter for that.
You can implement multiple counters, and process them in turn using a common ALU and bus structure. Something like the old AMD bitslice ALUs might be useful to make implementation easier; they have built-in register banks to store the counters, built-in add, subtract and compare operations, and so on. Extending the sample resolution to 16 bits would be a matter of adding a second 64KB RAM chip using the same address lines, and extending the mixer and DAC with the additional data lines.
This basic approach (though details of implementation obviously differ) went into the early Ensoniq 55xx chips which were used in high-end 1980s synthesizers and the Apple ][GS, having been designed by the same guy responsible for the SID.
Though what I'd do is to index over 64K addresses using a 20-bit counter, giving you 4 "fractional" bits. The increment value can be an offset 16 bits (so you now have 64K possible frequencies covering 16 octaves, depending on your sample length), while the start and wrap addresses can be 16 bits without offset. You can also try to use the wavetable RAM as a circular buffer for continuous playback; you'll need to be able to read back the upper 8 or 16 bits of the counter for that.
You can implement multiple counters, and process them in turn using a common ALU and bus structure. Something like the old AMD bitslice ALUs might be useful to make implementation easier; they have built-in register banks to store the counters, built-in add, subtract and compare operations, and so on. Extending the sample resolution to 16 bits would be a matter of adding a second 64KB RAM chip using the same address lines, and extending the mixer and DAC with the additional data lines.
This basic approach (though details of implementation obviously differ) went into the early Ensoniq 55xx chips which were used in high-end 1980s synthesizers and the Apple ][GS, having been designed by the same guy responsible for the SID.
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
64K samples for a cyclical waveform is probably hella overkill, though, at least for the OP's purposes. (Plus, it means loading new waveforms will take non-negligible time.) For simple chiptune-ey timbres, 16-32 samples for a single waveform cycle is quite sufficient, and Garth's suggestion of 256 samples is absolutely spacious.
I mean, in a hypothetical system with a master clock rate of 5 MHz, a cycle of middle C is only ~19K sample periods long to begin with, which means that over a third of the samples would be completely wasted anyway. And that's supposing that you don't time-multiplex the same hardware over multiple channels, in which case it gets even more inefficient.
(Of course, a large master wavetable that individual voices can use samples of different lengths from is the most balanced compromise in this situation - I know the Korg DW-8000 did this, switching to progressively downsampled versions of its basic waveforms as oscillator pitch moves up the scale, and I wouldn't be surprised if other wavetable designs do as well, since it also has the advantage that the higher-octave samples can be properly downsampled without having to have the hardware do so in real time. Provided that possible sample lengths are limited to powers of 2, it's not difficult to implement in hardware, either.)
I mean, in a hypothetical system with a master clock rate of 5 MHz, a cycle of middle C is only ~19K sample periods long to begin with, which means that over a third of the samples would be completely wasted anyway. And that's supposing that you don't time-multiplex the same hardware over multiple channels, in which case it gets even more inefficient.
(Of course, a large master wavetable that individual voices can use samples of different lengths from is the most balanced compromise in this situation - I know the Korg DW-8000 did this, switching to progressively downsampled versions of its basic waveforms as oscillator pitch moves up the scale, and I wouldn't be surprised if other wavetable designs do as well, since it also has the advantage that the higher-octave samples can be properly downsampled without having to have the hardware do so in real time. Provided that possible sample lengths are limited to powers of 2, it's not difficult to implement in hardware, either.)
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
commodorejohn wrote:
I mean, in a hypothetical system with a master clock rate of 5 MHz, a cycle of middle C is only ~19K sample periods long to begin with, which means that over a third of the samples would be completely wasted anyway. And that's supposing that you don't time-multiplex the same hardware over multiple channels, in which case it gets even more inefficient.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Basic Project Advice for 6502-based Synthesizer?
commodorejohn wrote:
64K samples for a cyclical waveform is probably hella overkill, though, at least for the OP's purposes. (Plus, it means loading new waveforms will take non-negligible time.) For simple chiptune-ey timbres, 16-32 samples for a single waveform cycle is quite sufficient, and Garth's suggestion of 256 samples is absolutely spacious.
https://github.com/hoglet67/Music5000/w ... efinitions
There are 128 samples for each waveform.
Here's a few notes from further down that page that talk about how the waveform generation works:
Code: Select all
These three 8-bit registers combine to give a 24-bit frequency register.
The Music 5000 runs off a 6MHz clock and takes 128 clock cycles to update all channels. This means each channel is updated at 46.875KHz. Every time the channel is updated, the 24-bit frequency value is added to a phase accumulator. The top 7 bits of the phase accumulate (which look like a ramp) are then used as in index into the 128-byte Wave Definition.
Here's an example.
Assume the Wave Definition contains a single cycle of a sine wave, and you want to generate a 1.0 KHz tone.
The frequency register needs to be set to:
2^24 * 1.0 / 48.875
= 343267
= &053CE3
So:
Frequency Lo = &E2
Frequency Mid = &3C
Frequency Hi = &05
Bit 0 of Frequency Lo must be zero, or the channel is disabled.