• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

Creating ' snd' resources

nightingale

Well-known member
I'm looking for help finding software to compose music using square wave and wave table instructiosn which can be saved to a ' snd' resources. I'm trying to create a soundtrack for my game that I'm developing, but haven't found any software that is suitable. The programs that I have found will convert other types of audio files to .snd files, but they are using sampled sound, which uses a lot of disk space. I'm specifically looking for something like a music tracker that will create a ' snd' resource using square wave or wave table data, which I assume will take up significantly less disk space than sampled sound files. A 2-minute sampled sound can be several megabytes, whereas a midi file of that length would be only a few KB. I'm really hoping that ' snd' resources which contain sound data to create music would be of a similarly small size compared to sampled sound.

Inside Macintosh: Sound talks surprisingly little about the difference in sound capabilities between the original Sony sound chip used in the first compact macs and the Apple Sound Chip used in later macs, other than to say that the ASC supported multiple sampled sound channels. Am I correct in assuming they would both be capable of playing ' snd' resources which contain square wave/wave table instructions?

Other than IM: Sound, can anyone point me in the direction of any books or other resources which go over creating music on early macs? Or suggest any music trackers which might achieve what I'm trying to do?
 

ymk

Well-known member
I didn't think snd resources could contain anything but PCM.

Wavetable instruments fall into that category, but I believe the MIDI data is a separate resource.

With SD-based disks being common, storage isn't nearly as precious as CPU cycles for 68000 Macs and music synthesis eats lots of cycles.

Prince of Persia uses MIDI and its own internal synthesizer, but most music playback is in the main menu or between levels. In the rare cases where there's music during gameplay, action slows down significantly on a 68000.

Cogito plays MOD music and Jewelbox uses PCM loops, but neither game offers music on a 68000.
 

sfiera

Well-known member
I wrote a decoder for ‘ snd’ resources at one point and I don't remember having to handle anything but sampled sound.

I remember seeing music in midi resources or ‘MADH’ (a module format from PlayerPro), but I don't know if the libraries you'd need to use them are available on 68000.
 

tashtari

PIC Whisperer
I could be wrong, but I believe there is some capability in snd resources for reuse of samples - the sample in the "Clink-Clank" alert sound in System 6 just contains the "clink", and something causes it to be played slowed down to make the "clank". I'm not sure this rises to the level of functionality in a MOD file, though.
 

nightingale

Well-known member
So perhaps I’m misunderstanding what the documentation meant when it said a snd resource could contain sound data and sound commands. The sound commands can alter the sound that is playing, but do you always need a sampled sound to start with? I read it as the sound manager could actually generate sound, but perhaps it can only play sounds and manipulate them?
 
Last edited:

sfiera

Well-known member
Hmm, indeed you're right. “Inside Macintosh: Sound” shows some examples of non-sampled format 1 ‘ snd’ resources starting on 2-76 and a list of command on 2-93. There's a discussion of paying sounds asynchronously starting on 2-46. So it does seem like it could, in theory, be used for background music.
 

nightingale

Well-known member
Yes, I’ve written the code to have sound play asynchronously during gameplay, it’s pretty straightforward. For testing I just used a random snd resource I found, but it’s recorded sound and compressed to the point it doesn’t sound great. But performance is good, even on the Mac Plus.

My goal is to have the game fit on an 800K disk, including a system folder. So space is my main constraint.

IM does indeed show you how to create sounds using sound commands, which in theory can be contained in a snd resource. I would be surprised if there wasn’t a utility that existed to compose music and save the sound commands to a snd resource, but haven’t found anything yet.

Also, Sex, Lies, and Video Games is a great book, and I’ve used it extensively as I developed my game.
 

ymk

Well-known member
I remember one of the early Chessmaster games used square wave music, but I'm not sure if it was in a snd resource.

Zero Gravity was another.
 
Last edited:

nightingale

Well-known member
So, just following up on this, I did a really quick and dirty test by hard-coding in sound commands into my game and telling them to play asynchronously:

SndNewChannel(&gChannel.channel, squareWaveSynth, 0, nil);

mySndCommand.cmd = freqDurationCmd;
mySndCommand.param1 = 600;
mySndCommand.param2 = 60;
SndDoCommand (gChannel.channel, &mySndCommand, TRUE);

mySndCommand.cmd = freqDurationCmd;
mySndCommand.param1 = 600;
mySndCommand.param2 = 80;
SndDoCommand (gChannel.channel, &mySndCommand, TRUE);

mySndCommand.cmd = freqDurationCmd;
mySndCommand.param1 = 600;
mySndCommand.param2 = 100;
SndDoCommand (gChannel.channel, &mySndCommand, TRUE);

mySndCommand.cmd = freqDurationCmd;
mySndCommand.param1 = 600;
mySndCommand.param2 = 60;
SndDoCommand (gChannel.channel, &mySndCommand, TRUE);

mySndCommand.cmd = freqDurationCmd;
mySndCommand.param1 = 600;
mySndCommand.param2 = 80;
SndDoCommand (gChannel.channel, &mySndCommand, TRUE);

And it does in fact generate square wave notes and play them in the background. According to IM, these sound commands can be contained in a snd resource and then I could just play them using the SndPlay function.

I haven't messed around with wave tables yet to try to generate something other than square waves, but according to the documentation, it should be possible. I should also be able to create multiple sound channels and synchronize them for more complex music (likely keeping it to a few channels so as to not bog down the CPU on a 68000).

So I guess I can quickly create a tracker application to compose the tunes and then save them to a snd resource myself. I'm just really surprised such an application doesn't exist.

I'll mess around more and see what I can put together.
 

register

Well-known member
Consider to fetch a copy of SoundEdit Pro. This beautiful piece of software allows you to open/record/edit sound data and to save it into a sound ressorce file.
SEP_export_format.jpg
To get hands on a specific ressorce file you would want to work on, have also a copy of ResEdit available.
 

nightingale

Well-known member
So I couldn't find a program that did what I wanted -- allow you to compose music using sound commands from the Sound Manager. So I created one! I am calling it SimpleTracker, and it is a very quick and dirty implementation which is not user friendly at all, but this was a proof of concept to see if the Sound Manager and the hardware even worked the way I thought, and they do!


Now this video is recorded in an Emulator, and I've noticed the sound generation sounds different on real hardware. I also still have yet to test this on older hardware to see if the older sound chips and OS can play these snd resources. This is also just using some simple wave tables I quickly created, but more complex sound should be possible.

In my game, each snd resource would be one channel of audio, so if my music has multiple voices, it will be played in multiple synchronized sound channels. In testing so far, I have no problems playing two of these snd resources during gameplay on my LC580. I haven't tested on the Plus or the SE/30 yet, so I'll try those and see if it works before putting too much effort into this.

If this works on the older hardware, then I have to wonder why music wasn't present in more early Macintosh games. Since these resources are just sound commands, a song would only be a few KB. Other computers of the era had chiptunes and some were quite elaborate. So why not the Macintosh? The Sound Manager can even take a short sampled sound, like playing an instrument, and alter it to make different notes, so in theory very elaborate music is possible without using much disk space. Though I think manipulating sampled sound is probably more CPU intensive. So was the focus just too much on the Mac's ability to play sampled sound, which used a lot of disk space, so music wasn't considered for mac games? And a lot of later Mac games used MIDI, which wasn't feasible on early Macs. But I'm a bit puzzled why chiptunes weren't a thing on early Macs.

I'm also still really surprised that a program like this doesn't already exist.

Anyway, I'll keep up with my testing and see if I can answer some of these questions. If things continue to look positive, I will eventually make a more polished version of SimpleTracker and post for others to play around with.
 

ymk

Well-known member
Good work! I didn't know that was possible.

If you're set on Sound Manager handling your music, consider writing a MIDI to SND converter.

That'll save you the trouble of writing your own sequencer among other obvious benefits.

Other computers of the era had chiptunes and some were quite elaborate. So why not the Macintosh?

Mostly because those computers had actual synthesizer chips that could generate music while the CPU was doing game stuff.

One could argue the ASC is a synthesizer, but I haven't seen any examples of it used for something like MOD playback.
 

Arbee

Well-known member
The ASC is mostly limited to stereo playback with no real synthesis of its own. There is a very, very limited 4 voice wavetable mode that's used for the Mac II-style boot chime, but you can't get into that mode under Mac OS. That capability went away entirely in later hardware, likely due in part to Apple Corps suing Apple in 1989 over the Apple IIgs's Ensoniq synthesizer chip, among other things.
 

CC_333

Well-known member
That capability went away entirely in later hardware, likely due in part to Apple Corps suing Apple in 1989 over the Apple IIgs's Ensoniq synthesizer chip, among other things.
Apple Corps is one of those infamously litigious companies that will sue you if you look at it wrong.

EA is (was?) another one, if I'm not mistaken.

It's a shame, really, as early Apples and Macs had much sound-making potential (as the copious amount of third-party hardware and software demonstrates). Apple Corps was being dumbly over-reactive, as I highly doubt that Apple Computer was interested in having anything to do with the record industry at the time (Apple's main focus at the time was in education, graphic arts and desktop publishing, none of which is related directly to music).

But, whatever. It happened, and despite it all, here we sit about 40 years later, and Apple owns and operates the iTunes Store, among the first and most successful of the first generation of legal, Internet-based music distribution platforms and Apple Music, which is one of the largest music streaming services (currently second only to Spotify).

Anyway, sorry for editorializing!

<we return now to the original program, already in progress...>

c
 
Top