But obviously the counter has to be able to access the entire address space of its attached memory, or some of the latter *definitely* goes to waste.
Basic Project Advice for 6502-based Synthesizer?
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.
But obviously the counter has to be able to access the entire address space of its attached memory, or some of the latter *definitely* goes to waste.
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
Chromatix wrote:
But obviously the counter has to be able to access the entire address space of its attached memory, or some of the latter *definitely* goes to waste.
Additionally, you don't necessarily need to max out the possible size of the sample memory, depending on other design choices. If, say, your maximum loop length is 256 samples, and your hardware design allows for a total of 8 8-bit voices, there's really no point in providing a sample memory larger than 4 KB, unless you're using techniques that change voice samples often enough that sample-copying overhead beomes a significant factor.
Re: Basic Project Advice for 6502-based Synthesizer?
Right, which is why I suggested a 20-bit counter of which the top 16 bits form the sample address, and the bottom 16 bits are addressed by the variable increment. The top 16 bits would also be where you should attach the wrap comparator and subtraction.
In practice you're unlikely to find a 32Kbit RAM to implement a 4Kx8 memory anyway, rather 64Kbit and up. If it's convenient to implement a 64KB memory - why not?
In practice you're unlikely to find a 32Kbit RAM to implement a 4Kx8 memory anyway, rather 64Kbit and up. If it's convenient to implement a 64KB memory - why not?
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
Chromatix wrote:
In practice you're unlikely to find a 32Kbit RAM to implement a 4Kx8 memory anyway, rather 64Kbit and up. If it's convenient to implement a 64KB memory - why not?
As for the "why," it's all dependent on the design strategy and how the OP wants to interface things. It's probably simpler to provide a fixed 4KB memory region that the synthesizer hardware uses than a mappable 4KB window into a larger region. Having each voice use a fixed range of addresses instead of a semi-arbitrary address within a large wavetable also means that's one less register for the software to keep track of, or if a select register is provided, it's at least significantly fewer bits. And going for a fixed wavetable region rather than (say) having the synthesizer hardware DMA samples from main RAM means there's no cycle-stealing going on outside of CPU accesses to wavetable RAM, if that's a thing the designer cares about.
I'm not saying that one technique is the only and inevitable ultimate and the other must ever grovel before it. I'm just saying that there are merits to both strategies and it depends to a significant degree on what the designer wants.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
commodorejohn wrote:
Well, yes in the sense that memory the voices can't address is memory that has no business being in the sample side of the architecture at all. But also no, in the sense that bits that can't directly serve as address bits to the sample memory can still serve a purpose as fractional values that allow for greater precision in frequency selection, which is a non-negligible factor in musical applications (you don't have to go very far up the scale in simple integer-clock-divider counter designs before the closest available output frequencies start being measurably off from the correct notes.)
Quote:
Additionally, you don't necessarily need to max out the possible size of the sample memory, depending on other design choices. If, say, your maximum loop length is 256 samples, and your hardware design allows for a total of 8 8-bit voices, there's really no point in providing a sample memory larger than 4 KB, unless you're using techniques that change voice samples often enough that sample-copying overhead becomes a significant factor.
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?
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
GARTHWILSON wrote:
I'm probably not understanding you correctly; but to be clear, in DDS, if the phase accumulator and the incrementer are both 16-bit, and you do 16,000 SPS, and you have a 256-sample table, each count of the incrementer is 1/65536 (ie, 1/256 of 1/256) of a wave, so you get 16,000/65,536K Hz resolution, ie, better than 1/4 Hz resolution, linearly, from deep-subsonic up to just below the 8kHz Nyquist frequency, or actually whatever your anti-alias filter can handle, perhaps 7kHz. A 1/8Hz error (which is the worst case, where you have to go a half of a 1/4 Hz increment one direction or the other to a playable pitch) at the low end of the hearing range is about 10 cents off, which is somewhat of an offense to anyone with a good sense of pitch—except that down there, you can't really discern the pitch accurately at all anyway. You would rely on the pitch of harmonics, or just see how many seconds it would take to complete a cycle of the beating against a reference, in this case more than eight seconds! At the lowest note the bass can play (if it doesn't have the C extension), the maximum error becomes about 5 cents. Up at A440, 1/8Hz error is less than half a cent. (Hopefully I don't have any errors in my math.)
Quote:
It's even better than that. 2KB.
256 8-bit samples, times 8 voices is 2KB. But you might want different tables for different ranges of notes for the same voice. For example, on my cello, playing the lowest notes on the C string does not give just a shifted-down spectrum of what I get playing one or two or three octaves higher. (I regularly get up to the top of the treble clef, over three octaves above the lowest note, but I don't feel confident playing above that in public, as intonation becomes more difficult, except sometimes in harmonics.)
Last edited by commodorejohn on Mon May 28, 2018 9:01 am, edited 1 time in total.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
commodorejohn wrote:
Quite right, and that's one of the advantages of the phase-accumulator design. I was speaking more in terms of simple linear down-counter designs like (for example) the NES pAPU, where the counter is simply loaded with a value and then decremented until it reaches 0, at which point the position within waveform is incremented. In that system, output frequencies can only be even divisions of the master clock rate, so that there are only two possible frequencies within an octave of the maximum rate, four within two octaves, etc. etc. But really my point is just that extra bits can still serve a purpose even if they don't get directly hooked to the wavetable address.
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?
It's notable, I think, that the Music 5000 has a 24 bit phase accumulator. I think that's an indication that 16 bits isn't enough. According to this, you'd need 23 bits if you were clocking samples at 48kHz. Of course, standards for 'musicality' are variable, unless you're selling your kit as a musical instrument.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
BigEd wrote:
It's notable, I think, that the Music 5000 has a 24 bit phase accumulator. I think that's an indication that 16 bits isn't enough. According to this, you'd need 23 bits if you were clocking samples at 48kHz. Of course, standards for 'musicality' are variable, unless you're selling your kit as a musical instrument.
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?
Or slave one phase-accumulator's increment rate to another wavetable, for a much more space-efficient implementation.
Re: Basic Project Advice for 6502-based Synthesizer?
I think this question stems from my ignorance of some implementation details (I looked up a few data-sheets of various counters and was still confused) but if the phase accumulator is tied to the same Φ2 as the CPU, doesn't that clock-speed impact the lowest representable frequency? Taking Garth's example, using a 16bit accumulator to index into an 8bit memory address space, the slowest sample period is 1 sample per 256 16bit increments. But isn't the speed of that incrementation dependent upon the Φ2? It seems to me like you could easily overshoot and make it impossible to represent the lower frequency range. I assume that carefully adjusting the Φ2 and the number of bits used by the counter could result in something that’s “just right,” representing the necessary range of frequencies, but I don’t think that’s what everyone is saying should be done. Garth mentioned using the interrupt handlers to control when playback happens, but I still need to read the interrupt primer
. In any case, I seem to be missing the more elegant solution that would handle this issue!
What exactly is the difference between a circular buffer and a buffer that is indexed by a counter that wraps over? It seems to me that if you’ve implemented the modulo operation that would wrap say, an 8bit address to a 4bit one, you’ve effectively tied the ends of a 16bit wide buffer together, right?
I’ll definitely need help with anti-aliasing at some point. I'm not too concerned now in as much as this design phase is pretty theoretical for me at the moment. Hell, I didn’t even know what was possible when I started the thread! Anyway, my current ‘lesson plan’ is to watch all of Ben Eater’s 8-bit breadboard videos (I’m about half-way through), then reading/rereading the primer. After that I’ll move on to deciding which kind of prototyping material to use, after which I’ll hopefully have a solid understanding of which design to use and why.
Chromatix wrote:
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.
Garth wrote:
Speak up if/when you need a design for an anti-alias filter you can make with cheap, commonly available parts.
Last edited by cynlic on Mon May 28, 2018 6:43 pm, edited 1 time in total.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
You could have different instruments on different vibrato rates, as would be normal for musicians playing together. There are more complicated things which although interesting, probably would not be addressed on a 6502-based synth, like the fact that with some instruments like flute and recorder, the color of the sound cycles with the pitch in vibrato, getting more airy and complex in the higher portion of the cycle. We also have not taken into account the attack sound for beginning notes on various instruments; but again that's getting pretty complicated, and if controlled by a keyboard, would definitely need one that senses how quickly the key went down, or some variation on that theme. Myself, if I really wanted all of that, I'd use a commercially available synth with MIDI, and use the '02 to feed MIDI commands. Actually I have done this, although I only took it far enough to show that I could, not far enough to do real music. I wrote a short tip about it at viewtopic.php?p=2313#p2313 .
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?
GARTHWILSON wrote:
BigEd wrote:
It's notable, I think, that the Music 5000 has a 24 bit phase accumulator. I think that's an indication that 16 bits isn't enough. According to this, you'd need 23 bits if you were clocking samples at 48kHz. Of course, standards for 'musicality' are variable, unless you're selling your kit as a musical instrument.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Basic Project Advice for 6502-based Synthesizer?
cynlic wrote:
I think this question stems from my ignorance of some implementation details (I looked up a few data-sheets of various counters and was still confused) but if the phase accumulator is tied to the same φ2 as the CPU, doesn't that clock-speed impact the lowest representable frequency?
Quote:
Garth mentioned using the interrupt handlers to control when playback happens, but I still need to read the interrupt primer
.
Quote:
Chromatix wrote:
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.
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?
Ah, what I meant by "circular buffer" was specifically for cases where you want to stream audio data continuously from some source, rather than using the sound hardware as an instrument. It's like a more general form of double buffering.
As for concerns about not being able to go slow enough - if you run into that problem in any practical scenario, just add more bits at the less-significant end of the counters.
As for concerns about not being able to go slow enough - if you run into that problem in any practical scenario, just add more bits at the less-significant end of the counters.