Thinking out loud:

One problem is that the timer doesn't run fast enough to be able to accurately play back high notes, so realistically I get about half of octave 0, octaves 1 and 2, and about half of octave 3 (and a few notes of 4). This is rather limiting.

I've been thinking about an alternative playback system, where I have a set of precomputed 'wavetables' for each note. Playback simply involves indexing into the appropriate wavetable. On the 6502 this can be super cheap:

```
lda note1, x
eor note2, x
eor note3, x
```

Changing notes is done by updating the addresses directly in the instructions. Because this is cheaper and faster, I can do it more often, and therefore increase my sample rate and get better high-pitched notes.

Except, now I need a 'sample' for every possible note. 80 notes at 16 bytes per sample is a bit over 1kB, which is fine. Except... those 16-byte samples won't necessarily contain complete waveforms. So there'll be a glitch every time the sample loops. If my sample loops every 0.01s, that'll produce a 100Hz tone.

Is this an approach anyone else has investigated? Is it at all workable? The downside is that I don't get on-the-fly waveform generation, which means no volume control; but my volume control is pretty bad anyway...

I think I forgot to post this here, but the stuff I was doing on 1-bit music on the 6502 a while back turned into a fully-fledged 3½-track tracker for it: https://cowlark.com/ptracker/ It's... crunchy. There's only just barely enough CPU for it to work, meaning there isn't even a progress indicator while playing, and I'm pretty sure that it's overrunning at times but luckily you can't tell given the sound quality!

So far I've done covers of Jugi's Onward Ride: https://www.youtube.com/watch?v=iqWJeM2MKt4 (as made famous by the DOPE demo)
...and Darude's Sandstorm: https://www.youtube.com/watch?v=qeUOBw00vq4 (as made famous by... everyone?)

Both were tracked using ptracker itself. (I'll also point out that tracking a piece of music that is essentially a single phrase repeated over and over for three minutes with minor variations has melted my brain.)

It uses the CB2 FIFO on the PET's 6522 to do most of the heavy lifting so I suspect it's doubtful if the engine would port easily to other 6502 systems (unless they also use CB2 for sound; are there any?)...

3

(3 replies, posted in Other Platforms)

I'm building Apple 2 disk images for my CP/M-65 project. The crucial bit is shuffling the image into the right sector order because the bootloader uses this wretched soft sector remapping. I've got a tool here: https://github.com/davidgiven/cpm65/blo … shuffle.cc The right order is 02468ace13579bdf...

I wasn't aware that anyone had done softsynths for the Apple. I thought I was the first to do it on a 1MHz 6502 on the PET! I'd be interested to see how they work; I had a great deal of difficulty fitting 3.5 channels into the available CPU time, and that was with using a 6522's shift register to do much of the heavy lifting.

I tried reverse engineering Tim Follin's Startip 2 music track and engine and porting it to the PET. It went... not great.

https://www.youtube.com/watch?v=B_SmzoQJBsQ

The issue is that the playback engine has got extremely ad-hoc timing. Every bit of it takes as long as it takes with no attempt to synchronise timings anywhere. So, depending on how much work it's doing, the pitch will change slightly. Because my new engine is using a different architecture, all the timings are different, and it's all fundamentally untunable. I suspect Follin simply did everything by ear. I've found transcriptions of this track, and the same note in different contexts will be represented by a different value in the data. To make it work I'm pretty sure I'm going to have to retranscribe the music from scratch, and, well, then it's not the same engine any more, so I'm going to leave it here.

Anyway, I thought people might be interested to see this.

Source: https://gist.github.com/davidgiven/ca16 … bef4504526
.prg: https://drive.google.com/file/d/1jRVbj3 … ?usp=drive

(I'd be interested to know what it sounds like on real hardware.)