It’s something that has been kicking about in my head. Has it been implemented? Could it be implemented? I can imagine the Commodore compatibility would make it troublesome, but I’ve never worked with any kind of machine older than Windows 98. That being said, the spec for the AA-Machine interests me, and I have been picking through it when the mood strikes me.
Short answer: yes, but currently only on web.
The Å-machine’s media handling is very basic, pretty much just one opcode for “can this interpreter embed this piece of media?” and one for “now embed this piece of media”. When I wanted background music for The Wise-Woman’s Dog last year, I added audio support to the web interpreter, with no change to the Å-machine spec itself. I just made the web interpreter say yes, it can handle audio files, and defined what it means to “embed” one. In theory someone could do the same for the C64 interpreter, but so far nobody has.
(It did require a slight change to Dialog’s syntax, to specify options like looping, but resource option strings were actually in the Å-machine already. Dialog just never emitted them before.)
Okay. I trust that’s in the web interpreter that comes with the AA-Machine, or is it something you only implemented on your own copy?
Originally in my copy, but it’s now in the main repo version.
Basically, you just declare your audio file like you’d declare any other file:
(define resource @music) music.mp3; some subtle background music
And then embed it:
(intro)
You hear music playing through the trees.
(if) (interpreter can embed @music) (then)
(embed resource @music)
(endif)
And it should start playing!
If you want to configure how exactly it plays, you add options between the filename and the alt text:
(define resource @music) music.mp3, loop, channel: bg; some subtle background music
Now it will loop forever, and will play specifically on the “bg” channel. If you play another audio file on the same channel, the original one will fade out before the new one starts; this means you can stop an audio track by playing a moment of silence on its same channel.
This is how I did it in The Wise-Woman’s Dog:
(define resource @village) resources/seikilos.ogg, loop; the Epitaph of Seikilos, adapted and performed by Michael Levy
(define resource @temple) resources/hurrian.ogg, loop; the Hurrian Hymn to Nikkal, adapted and performed by Michael Levy
(define resource @bazaar) resources/priestess.ogg, loop; “Dance of the Priestesses” by Michael Levy
(define resource @silence) resources/silence.ogg %% No alt text since we embed this to *stop* music
(late on every tick)
(music enabled) %% Can be disabled in the OPTIONS
~(ongoing action $) %% Not in the middle of an ongoing action
(refresh music)
(refresh music)
(current room $Room)
($Room uses music track $Track)
(if) (interpreter can embed $Track) (then)
(embed resource $Track)
%% (par) Playing: $Track
(endif)
Why do I refresh the music on every tick, rather than only when it changes? So that when someone loads a saved game, including an autosave, the music will kick in on the next turn. I specifically made it so that embedding the same resource multiple times in a row won’t restart the track, so it won’t stutter back to the beginning every turn.