Kernal & BASIC sound API for the ROM - ideas?

Chat about anything CX16 related that doesn't fit elsewhere
ZeroByte
Posts: 714
Joined: Wed Feb 10, 2021 2:40 pm

Kernal & BASIC sound API for the ROM - ideas?

Post by ZeroByte »


A few notes about the API side of things - this code is accessible through an API located in ROM bank $0A. (A for audio - it was Kismet)

In addition to the underlying BASIC code, there are atomic routines for setting the pitch, volume, and panning for each voice/channel of the two chips, as well as a set of functions to easily convert the pitch values between various formats (PSG's F-number, YM's KC+KF, Raw HZ value, and MIDI note numbers).



For the YM2151, the code maintains a RAM shadow of the values being written into the chip so you can now make programs that do read-modify-write style actions on the YM2151 (the chip itself is write-only, unlike the PSG) which opens a lot of possibilities for sound engines.



You're not limited to using these note-centric functions, either  (fm/psg_note, fm_trigger, etc). So long as your programs only write data to the chips using the API calls (ym_write and psg_write), the volume attenuation and panning features will still be effective, which makes writing sound engines just a bit easier.

Edmond D
Posts: 476
Joined: Thu Aug 19, 2021 1:42 am

Kernal & BASIC sound API for the ROM - ideas?

Post by Edmond D »



On 1/3/2023 at 2:54 PM, ZeroByte said:




This has definitely turned out to be quite a featureful enhancement for BASIC as well as the functionality available as low-level calls. @MooingLemur has produced tons of useful code for this project, and @Jestin on the BASIC parsing side of things. I'm excited because this will build in a nice set of functionality that makes playing music on the YM2151 and PSG much easier for anyone, regardless of the programming language in use.



 



Thanks to you, @MooingLemur and @Jestin for developing this basic extension. It gives some hope to us who are musically impaired.

MooingLemur
Posts: 33
Joined: Sat Feb 19, 2022 4:44 pm

Re: Kernal & BASIC sound API for the ROM - ideas?

Post by MooingLemur »

Here is a preview of a program I've started writing that takes advantage of the (not yet accepted and merged) KERNAL audio API. It's a MIDI file player for X16 that uses the YM2151. It takes advantage of the General MIDI compatible instruments and drum patches being in ROM, and it uses the volume/attenuation abstraction for note velocities and volume slides.

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

For now, the UI is mostly a mockup, but I feel like it's come pretty far in less than a week.

Once emulator R42 comes out, and assuming the audio bank is accepted, I'll plan to release a more polished version of this into the downloads section.
Post Reply