As I dig into the implementation of a more modernized audio support for Unix Frotz, I started wondering if the specs allow for multiple sounds to be played at once. The writer of sfrotz apparently wrote his code such that only one sound can be played at once. I can’t seem to find a reference to this and I’m at the point where I decide whether or not to write my code to support this.
For the Z-machine, only one sound effect can be playing at once with the caveat that it might be possible for bleeps to play while another sound effect is already playing.
Relevant sections from the Z-machine Standards Document:
9.4: Bleeps are immediate and brief. Other sound effects take place in the background, while normal operation of the Z-machine is going on.
9.4.2: A sound effect (other than a bleep) can then be “stopped” or “started”. Only one sound effect is playing at any given time, and starting a new sound effect automatically stops any current one.
Remarks: if a new sound effect is begun while there is still one playing which was started since the last keyboard input, then wait until that earlier one finishes one cycle before replacing it with the new sound effect.
It’s clear that bleeps cannot play over top of each other and that sound effects cannot play over top of each other. It seems that it’s possible, however, for a bleep to play while a non-bleep sound effect is playing. Basically, if “sound effect” is always read to mean bleeps + external sounds, they can never play simultaneously. If it’s read (in 9.4.2 and the Remarks) to refer only to external sounds, then bleeps can play at the same time as external sounds.
In Glulx, yes, you can play multiple sounds at once.
The current Glulx spec has sound features which, to my knowledge, no interpreter even supports yet. But you don’t need those to get multiple sounds playing at the same time - the previous spec already does this.
The extension ‘Multiple Sounds’ by Massimo Stella, and which I had a hand in updating, can get you going. It has some coding shortcomings in it at the moment (that might be my fault - I granted more powers without tydying up their consequences, which I was unaware of at the time) but that’s where to go to get started with playing sounds on multiple channels.
Windows Glk based interpreters (Windows Glulxe and Windows Git) and the Windows Inform 7 front-end support everything sound related in the latest Glk spec, as far as I’m aware.
Like all that in-built audio fading and stuff? For real and for true? Last time I asked about it, Zarf said no interpreters supported it yet, but maybe I asked longer ago than I think I did.
Edit: OK here’s a topic, and actually you (David) replied and said the stuff was in certain interpreters:
If it’s still only on Windows, I’m personally not gonna use it, since I’m authoring on Mac. My litmus test for any feature is: Is there at least one interpreter on each of Mac and PC that supports it? But that’s just me. As far as I can tell, nobody in the world has used these particular features yet.
I’m actually looking at adding sound to my Windows 8 Store version of Shadow in the Cathedral. This has led me to think about the functional application of sound separate from the implementation. Turn based games don’t have the same “always on” execution model, but the interpreter can recognize timed events. But how would an author want to implement sound?
- play a sound n times in a loop starting now
- play a sound once now
- play a sound every 10 seconds forever starting now
- play a sound once in 10 seconds
So is that the break down? Identify the sound file, the frequency, and the duration?
Does this sum up everything? What am I missing?
Just fades. You’ll most likely want some fading in or out in some circumstances to avoid an unceremonious immediate clunking of audio. EG Fade out title page music rather than just go immediately silent when player hits a key.
In the latest spec, Zarf built in the ability to execute fades (Yay! and thanks) though no-one has used it yet. Prior to this situation I manually programmed some fades, and they weren’t easy to effect without crackling.
The best way to get someone to implement features in an interpreter is to use them in a game …
I can’t program these features. They’re not supported in the IDE, I don’t know I6, and even if I did, I can’t play them back on my own computer because Zoom won’t interpret them and Gargoyle won’t interpret them
In a few days I should be pushing some new Frotz code which enables Blorb-encased sound. I added MOD and OGG sounds to a test game to check things out. First, I noticed that cblorb is required to correctly wrap up mods and oggs. Second, I noticed that sfrotz will, in fact, allow AIFF samples to be played while a MOD or OGG is also playing. This results in the two sound streams mixing. Multiple MODs and/or OGGs cannot play at once. It seems to me that the author of sfrotz is labeling all AIFF samples as “bleeps” which, as described above, can play over other sounds. Does this behavior make sense? Would it be a good idea to code Unix Frotz to behave as sfrotz currently does?
Sorry to reply to a question with a question, but does anyone know where all the support for MODs start coming from in IFdom? I’ve only played one game that plays a MOD (Dragon Hunt.) The thing that sucks/sucked about the format is the great lack of uniformity. There were all these trackers and they often had features the others didn’t support. And you’d end up making MODs that played on your software and no-one else’s. Only by sticking to the plainest features could you make a MOD with much cross-platform portability.
The only reason I can imagine people thought it might be a good music storage system for IF games (15+ years ago) is that it is not wasteful of space. But since drive sizes and space have grown exponentially, that’s no longer much of a reason to keep supporting what I always assessed as a horribly fiddly format. Also, MODs relied on low quality samples to keep space down. By the time you loaded in a few high quality samples today, you’re losing any size advantage a MOD might have had over an mp3 or ogg of a finished product made from the same high quality samples. Not to mention the complexity now achievable with even Garageband compared to a MOD tracker.
I think the attraction is that a mod represents something more akin to an old-school synthesizer. I’m using libmodplug to play mods in Unix Frotz. That library seems to handle everything except for the exceptionally rare Funktracker modules.
I seem to recall Screamtracker being capable of editing and playing .xm and .mod files as well as .s3m.
I’d like to bet that libmodplug doesn’t play the product of Mac OS Classic tracker Meditor, but I can’t bet or test that because I no longer have my songs
I probably gave the impression I think MODs kinda suck. I like MODs. I think they have their own aesthetic due to their technical qualities. Part of it is that you have to make a virtue of certain kinds of repetition and part of it is the particular sample quality. And, as you say, their pattern based design is reminiscent of hardware samplers/synths. But I still don’t get why someone said ‘let’s put these in IF games’, and then why people kept supporting the feature over years when it looks like one of the least utilised which has also been technically eclipsed.
Probably because they’re extremely easy to support, due to libmodplug or libmikmod.
And it was a way to get a lot of music into a very small space. And it looked popular enough that authors might use it. (This was 1997-ish.) This turned out not to be the case, but it was worth a try.
.MODs could be incredibly useful in easily providing situation-variant background music while maintaining a non-bloated game distribution size, but there’s not a huge overlap between the people who make text adventures and the people who make tracked music (strangely, since a chiptune and a piece of IF are about at the same place on a techno-minimalist spectrum.) Basically, the problem is that not enough games take place during a demoparty, where the music is inescapable.
Multimedia in games generally is an un(der)explored territory, because integrating it well and tastefully – to the betterment of the work, basically – is very difficult to reconcile. But there are enormous quantities of essentially public domain .MODs out there in the world, maybe incorporating them into a game could be the subject of one of our community’s multifarious compos someday.
That’s a valid point, but does the z-machine / Glulx have the capabilities to take advantage of that, though? (That’s a genuine question, btw, that I don’t know the answer to.) If the mod is no different to the game than any other sound file (such as ogg vorbis), then Ogg Vorbis would in most cases be the better choice even if the music was created in tracker software.
Originally I had a plan for doing exactly that – providing MOD audio files with shared samples, so that you could add lots of tracks for free (as long as you didn’t change the instrumentation).
Not sure it ever got implemented, because it was outside what libmodplug/mikmod could handle. It’s deprecated now.
Is that what the SONG format was about?
Yes, that’s what that was.