Do you happen to know if setting the frequency of an SN channel will reset its phase?
51 2024-03-13 22:32:58
Re: 1-bit sound on BBC Micro / Acorn Electron (26 replies, posted in Other Platforms)
52 2024-03-12 21:17:26
Re: 1-bit sound on BBC Micro / Acorn Electron (26 replies, posted in Other Platforms)
Ah, good. I'm really too tired to dig into this today.
I wonder what causes that high-pitched whine. This and the slow speed makes me think that the engine isn't running at the 2MHz I was assuming. Are there any interrupts still active? Are there any additional delays when writing to the SN, or is it possible that video is causing some blockage?
Optimizing the data read will only get you so far. Since the overall volume is low, row transitions will always be noticable. You might gain more by writing to all 3 tone channels instead of just one, provided you can make the inner sound loop run fast enough.
You might also consider mapping each Tritone channel to it's own SN channel. That would make things less timing critical.
53 2024-03-11 21:48:55
Re: 1-bit sound on BBC Micro / Acorn Electron (26 replies, posted in Other Platforms)
Ah yes, sorry, Tritone has indeed only global tempo. Also, yes, speed value = row length, and that should be bne play_note.
I'll have to dig deeper, then. Hope I'll have some time tomorrow.
I was actually thinking you might want to bypass 1tracker and just dump directly to asm data, so you can save one conversion step and design the data format and loader however you see fit.
54 2024-03-11 20:02:57
Re: 1-bit sound on BBC Micro / Acorn Electron (26 replies, posted in Other Platforms)
Spotted another one - you're missing the row length counting, ie.
dex ;2 row length low byte
beq .play_note ;3 -- 95 ~ 21053Hz (original is 22876Hz)
dey ; row length hi byte
beq .play_notewhere X should be 0 on init, and Y should be whatever Tritone spits out as row length. I don't have Tritone's data format at hand right now but iirc it should be the first byte of a pattern row.
55 2024-03-11 13:59:42
Re: 1-bit sound on BBC Micro / Acorn Electron (26 replies, posted in Other Platforms)
One thing I spotted skimming through quickly is that you're loading a drum marker per tone channel, but there's only one global drum channel in Tritone.
56 2024-03-07 09:17:12
Re: 1bit music, chiptune on a French podcast (2 replies, posted in General Discussion)
Wow, didn't know Stephane Picq was still active ![]()
My French hasn't gotten any better over the years so I'm afraid listening to that much of it in one go will make my head explode, but somebody should pester these guys to play some modern 1-bit stuff.
57 2024-03-07 09:10:55
Re: Collection of all 1Tracker .1TM songs. (6 replies, posted in General Discussion)
58 2024-03-05 19:30:12
Re: 1-bit sound on BBC Micro / Acorn Electron (26 replies, posted in Other Platforms)
Alright, so the gist of (equal volume) Tritone is basically this:
ldx #$0 ; reset row length counter lo byte
.play_note
clc ;2 update osc
.ch1_div_lo
lda #$0 ;2
.ch1_acc_lo
adc #$0 ;2
sta .ch1_acc_lo+1 ;4
.ch1_div_hi
lda #$0 ;2
.ch1_acc_hi
adc #$0 ;2
sta .ch1_acc_hi+1 ;4
.ch1_duty
cmp #$0 ;2 compare against duty threshold
sbc .ch1_acc_hi ;4 A = 0 on low half-cycle, FF on hi half-cycle
and #%00001111 ;2
sta SYSVIA_ORAS ;4
clc ;2
.ch2_div_lo
lda #$0 ;2
.ch2_acc_lo
adc #$0 ;2
sta .ch2_acc_lo+1 ;4
.ch2_div_hi
lda #$0 ;2
.ch2_acc_hi
adc #$0 ;2
sta .ch2_acc_hi+1 ;4
.ch2_duty
cmp #$0 ;2
sbc .ch2_acc_hi ;4
and #%00001111 ;2
sta SYSVIA_ORAS ;4
clc ;2
.ch3_div_lo
lda #$0 ;2
.ch3_acc_lo
adc #$0 ;2
sta .ch3_acc_lo+1 ;4
.ch3_div_hi
lda #$0 ;2
.ch3_acc_hi
adc #$0 ;2
sta .ch3_acc_hi+1 ;4
.ch3_duty
cmp #$0 ;2
sbc .ch3_acc_hi ;4
and #%00001111 ;2
sta SYSVIA_ORAS ;2
dex ;2 row length low byte
beq .play_note ;3 -- 95 ~ 21053Hz (original is 22876Hz)
dey ; row length hi byte
beq .play_noteIf you want to use unequal volumes (which could definitely come in handy), you need to shift the outputs around a bit somehow. In the original unqual volume, the outputs are distributed at a ratio of 34:49:70 cycles.
As far as data reading goes, I didn't bother since you're probably better off just design your own data scheme.
Noise mode can be tacked onto this design easily by adding
rol
adc #0after adding chx_acc_hi, and using #$2174 as frequency divider value. The duty setting will act more or less as a volume control on that. Or tack on the PWM sample code from SquatM, but beware that this engine is overall much quieter, so PWM samples at full blast may be too loud. Speaking of quiet, I think this will be the main problem with this code - it'll probably be too quiet on the SN, so you might want to write to all 3 tone channels instead of just one. Or even better, output each channel on its own SN tone channel.
As to why the sound is so noisy/muffled, I don't know enough about the beeb to help you there. Are there any waitstates/badlines/whatever it's called to be aware of?
Btw, that comment on youtube suggesting to use the shift register is a good lead, I think. Not necessarily as a hardware mod like the guy is suggesting, but as a means to offload some processing.
59 2024-03-04 13:56:53
Re: 1-bit sound on BBC Micro / Acorn Electron (26 replies, posted in Other Platforms)
The BBC Micro uses an SN76489. The Acorn Electron has no dedicated hardware for sound - it uses a ULA. I can adapt the code for the Electron fairly easily once there's a working SN76489 version.
Ok, now I understand your plan. I was kind of betting on being able to just use SN volume to render PWM frames, but so this has to be done the proper 1-bit way.
utz wrote:Also, am I correct in assuming that I could just keep pumping out DATA bytes (LATCH = 0) to set the volume of a given channel?
That's correct - it's pretty much what the SquatM engine is doing:
ora #%10010000 ; bit-7 (latch/data), bits-6/5 (channel - 0), bit 4 (type - latch volume)
sound_write_slow ; output sound bit
Sorry, I meant taking this even further: only ora #%10010000 at the beginning, and then just use the active latch to set the lower 4 bits, without needing to set channel and type again. Though considering how quiet the SN is at the 50% base volume we get by setting period to 1, it might be necessary to actually set multiple channels at once.
60 2024-03-03 22:36:57
Re: 1-bit sound on BBC Micro / Acorn Electron (26 replies, posted in Other Platforms)
Ah, so we're targetting SN76489. I assumed there might be some sort of native device.
Would it be acceptable to leave Port B I/O in WRITE mode and only switch to READing between pattern rows? That would speed up things quite a bit.
Also, am I correct in assuming that I could just keep pumping out DATA bytes (LATCH = 0) to set the volume of a given channel?
61 2024-02-29 20:27:20
Re: 1-bit sound on BBC Micro / Acorn Electron (26 replies, posted in Other Platforms)
So, regarding optimization options, 1tracker has a row optimization thingy that you can access with Ctrl-F4. That'll only save you a couple of kb though.
Otherwise you'd need to write your own optimizer that breaks up 1tracker's long single pattern into a sequence of smaller chunks, emitting duplicates. If you can afford to unpack into a large buffer at runtime, you could also just compress the player+music data. Something like ZX0 usually does a pretty good job for that.
Btw, Empty 512 Bytes sounds surprisingly convincing, despite such crude limitations. You would probably get much further with a Tritone-like engine, though. @xxl to the rescue, perhaps you could share your GTIA port? Otherwise, it shouldn't be too difficult to port the z80 code. If you give me a summary on how things work on the BBC Micro side (ie. how to output sound, disable interrupts, available zp locations, standard compile address, etc), I could try to whip up a rough 6502 draft. Will take a few days before I get around to that, though.
62 2024-02-29 19:41:57
Re: Welcome to the 1-Bit Forum (aka The Introduction Thread) (52 replies, posted in General Discussion)
Hello there bataais, welcome aboard! I'm liking a lot what I'm seeing on your blog. Our forum is mostly about music as you can see, but I'm very interested to hear more about your video projects as well.
63 2024-02-26 10:39:59
Re: 1-bit sound on BBC Micro / Acorn Electron (26 replies, posted in Other Platforms)
Hi, I'm pretty pressed on time atm so will try to answer in more detail in the coming days. For now just a couple of quick replies:
I'm wondering if there are options to optimize this file automatically, as compiled with player is over 27kb (out of 32kb available)?
No automatic options, I'm afraid. Generally it is possible to optimize the song data though.
I'm also interested in whether any of the other engines have been ported to the 6502 (or variants) with source code available? My Z80 knowledge to do this myself isn't up to the task.
Ports exist, but none with source available.
Finally, a long shot but does anyone have ideas on how to convert SN76489 LFSR noise to SquatM noise/percussion? (fixed rather than tuned).
Eh, finally some good news. Yes, this can be done. If you can generate the bitstream from the LFSR, you can convert it to SquatM's PWM sample format, which is basically just a bitstream with run length encoding. So eg. %1111000000011000000111000011 becomes 2,4,3,6,2,7,4,0 - the final 0 is the end marker.
64 2024-02-21 12:44:57
Re: ZX Touch console (2 replies, posted in Sinclair)
Pah, kids and their hipster gadgets nowadays ![]()
There are plenty of z80 instructions which are neither 4 cycles nor a multiple thereof, so that statement is kind of bollocks. Sampling every 4 cycles should still be good enough though, since most beeper engines align output to 8 cycles. To do things properly however one should sample at every clock cylce, and then apply a low-pass at half the sample rate of the emulated output.
65 2024-02-18 15:22:32
Re: new engine: PhaserF (5 replies, posted in Sinclair)
I could also pre-generate the tables, if that helps.
66 2024-02-17 15:37:10
Re: Jupiter Ace (6 replies, posted in Other Platforms)
Another weird method of controlling a speaker is found in the 8080-based Soviet DIY computer RK86. It lacks any interrupts whatsoever, so EI/DI control the speaker.
The PTC Sol-20 Music System is another (very early) example of this. Coincidentally it's also an 8080-based machine, though the Music System itself is an S100 card.
I have since experimented with 1k2b but unfortunately didn't get very far
On ZX81 it's actually a little more complicated since you write to port #ff, but read from port #fe. So if you comment out lines 64-66 and 85-87, and change line 206 to 'ld bc,#01fe', you should be nearly there, save for the drums. Really, don't torture yourself with 1k2b though. that's a horrible piece of code. Funnily enough, these new engines I made (ulasyn and PhaserF) should be fairly straightforward to port.
67 2024-02-16 20:29:07
Re: Jupiter Ace (6 replies, posted in Other Platforms)
Ah, that's similar to how it works on ZX81, which isn't surprising considering the machine's history. A rather inconvenient setup for 1-bit music, but not impossible. You'll probably want to write your own engine for this though, rather than porting an existing one.
Just how many different machines do you have in that barn of yours, though? ![]()
68 2024-02-06 19:15:07
Re: new engine: PhaserF (5 replies, posted in Sinclair)
What would be the challenge for adding it to 1tracker? The data format is quite similar to ulasyn's. In terms of interface, it could be shown as 4 channels, perhaps calling them 1A, 1B, 2A, 2B.
Btw forgot to mention in the readme that row length is 6-bit only, due to using the I register for counting.
69 2024-02-06 00:05:45
Topic: new engine: PhaserF (5 replies, posted in Sinclair)
As promised, here it is, Phaser with filters.
- 2 Phaser channels, XOR/OR/AND mixing
- variable duty for both oscillators (channel 2 only)
- volume control (up to 6 levels)
- filters with variable cutoff (6 levels for lo-pass, 5 levels for hi-pass)
- sample rate 9114 Hz
- interrupting PWM sampled drums at 27343 Hz with 7 pitch and 3 volume levels
- player size 3333 bytes (when assembled at a 256b border)
Channel 2 can be split into two independent pulse wave channels that are mixed
Squeeker-style (OR mixing). Beware that changing channel 2's mixing mode is slow
(~200t), so avoid doing so if you are concerned about transition noise.This one was quite a challenge, and I'm not entirely sure if it was worth the effort. Somehow it sounds muddier than ulasyn. Part of it is because length counter updates are slower, but there might also be a bug lurking in one of the volume cores. I've checked them all multiple times in various ways though, and can't spot any obvious culprits.
PWM drums are slightly different from ulasyn - higher sample rate, but less volume resolution. There's no noise mode in this engine, so the samples need to make up for it.
70 2024-02-05 23:57:09
Re: new engine: ulasyn (9 replies, posted in Sinclair)
Squashed one more bug today. Also tried to implement resonance, but either I'm doing it wrong, or the volume resolution is insufficient to do it. In any case, this should be it, not planning to do more work on this in the near future.
Would be great to have it in 1tracker. I'm not adding it to Bintracker yet, because the engine plugin format still isn't stable.
71 2024-02-03 23:37:28
Re: new engine: ulasyn (9 replies, posted in Sinclair)
Fixed some bugs, and found a way to properly calculate the cutoff 1.5 tables (by doing level 2 on a rising edge and level 1 on a falling edge). In theory this could be extended to other intermediate levels, doubling the cutoff resultion. However the filter response is such that the perceived difference between eg. level 2 and 3 is actually smaller than between 1.5 and 2, so I didn't bother implementing any more *.5 tables. Users can add their own filter tables if needed.
72 2024-02-02 20:18:32
Re: new engine: ulasyn (9 replies, posted in Sinclair)
Aaaand voilà. Volume control implemented. Lower volume means less precision for the filters, of course. Updated source is on github, see above.
Now what I would really like to have is resonance. Not sure if it's actually possible with this setup. In any case I can't wrap my head around the math of it.
73 2024-02-02 11:22:57
Re: new engine: ulasyn (9 replies, posted in Sinclair)
Ha, last night I realized that volume control is actually possible with this engine. It just requires lots of additional filter tables, but that can be done without increasing the code size.
Anyway, thanks guys.
74 2024-02-01 15:34:33
Re: A virtual 1-bit hardware proposal, 1-BOY (9 replies, posted in Other Platforms)
Ah, L/C/R panning definable in software, excellent. Like the idea of a RISC V MCU, too. How does it fare in terms of price, though? Mouser claims they're selling a ESP32-C3 for around 1€ over here, but pretty much any other seller is asking around 20€.
75 2024-02-01 00:43:40
Re: A virtual 1-bit hardware proposal, 1-BOY (9 replies, posted in Other Platforms)
Yes, that all makes a lot of sense. Also, damn, I keep forgetting that AVR is a Harvard arch.
About the sound system, my main concern at this point would be that it becomes too powerful. 8x1-bit with auto-reset would be wild, of course, but at some point it becomes tempting to treat the whole thing as a quirky kind of DAC and stream PCM on it, similar to how it works on RaspPi.
Btw, any plan for how to implement WiFi yet? I imagine this would add quite some complexity, in addition to possibly needing to introduce not-so-open components to the design.