'csnd' resource format

Sage
Posts: 1,403
Joined: 2005.07
Post: #1
I need to decode 'csnd' resources that I can get hex dumps from viewing some wolfenstien data files in res edit,
I know that they are the sound files in game and I've done a _lot_ of searching the net and found very little,

Any information about the format would be greatly appreciated and would help me hugley, I dont mind reinstalling MPW to compile classic app's if they can play csnd's.

I've found this much information so far:

Apple II File Type Notes Wrote:Here's how we would have upgraded AIFF to handle compressed audio, if we had
had a Format Version Chunk already in AIFF:

o Compression is optional. What follows is only for the compressed case.
o Don't change the format of the COMM Chunk. Existing programs can still
read it.
o Add a "Compression Descriptor" Chunk containing the 4-letter compression
type code and the compression name string. (The code is for programs.
The string is for alerts when the code is unrecognized.)
o Replace the SSND Chunk with a Compressed Sound-Data Chunk "CSND".
(Existing programs will ignore it.)

o Change the Format Version date (for the sake of alerts).
o Add the optional Saxel Chunk.

SoundMusicSystem.h Wrote:/*
** SoundMusicSys.h
**
** Structures for handling the sounds used by system
**
** © 1989-1994 by Halestorm, Inc, All Rights Reserved
...
** 5/20/91 Added csnd compressed resource based upon the LZSS algo.
...
** 9/19/93 Exposed DeltaDecompressHandle for Larry, for those who want to decompress a 'csnd' resource
...

The Halestorm SoundMusicSystem lib is a predecessor to QuickTime Music Architecture (and beatnik).

Thanks to anyone who can give me some more information about this file format, I'm really stuck here, but I will continue searching.

Edit:
I've uploaded some of the sound files extracted from the game, with thier DLZSS'd counterparts (and the program to decompress them). I'm not 100% sure that im DLZSS'ing them correctly but I tested this algorithm before and it works for the bitmaps.
So for anyone willing to take a look http://www.fax.xmgfree.com/DLSZZ.zip

thanks again!

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
In case anyone is searching the net for csnd stuf and so on, I got it to work
The Halestorm SoundMusicSys.h has a function for exporting the waveform of a sound so I just copied and pasted the appropriate wolf3d code and made it play the sound and export it, then you can play the raw sound file with anything you like Grin


Code:
#include <Types.h>
#include <Memory.h>
#include <Quickdraw.h>
#include <Fonts.h>
#include <Events.h>
#include <Menus.h>
#include <Windows.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <OSUtils.h>
#include <ToolUtils.h>
#include <SegLoad.h>
#include <Sound.h>

#include <stdlib.h>
#include <stdio.h>

#include "SoundMusicSystem.h"
#include "Sounds.h"

#define MySoundList 135    /* List of sound effects to log */

typedef unsigned int Word;
typedef unsigned long LongWord;

//typedef unsigned char Byte;
//typedef unsigned char Boolean;
    
/* Prototypes */
void * LoadAResource(Word RezNum);
void * LoadAResource2(Word RezNum,LongWord Type);
void ReleaseAResource(Word RezNum);
void ReleaseAResource2(Word RezNum,LongWord Type);
void PlaySound(Word SoundNum);
Word getSoundID(Word SoundNum);

//#define    PurgeSongs(purge)            MusicDriverHandler(kPurgeFlag, (long)(purge));

void * LoadAResource(Word RezNum)
{
    return (LoadAResource2(RezNum,'BRGR'));
}

Handle RezHandle;

void * LoadAResource2(Word RezNum,LongWord Type)
{
    Handle MyHand;
    
    MyHand = GetResource(Type,RezNum);
    if (MyHand) {
        RezHandle = MyHand;
        HLock(MyHand);
        return *MyHand;
    }
    return 0;
}

void ReleaseAResource(Word RezNum)
{
    ReleaseAResource2(RezNum,'BRGR');
}

void ReleaseAResource2(Word RezNum,LongWord Type)
{
    Handle MyHand;
    
    MyHand = GetResource(Type,RezNum);    /* Get the resource if available */
    HUnlock(MyHand);    
    HPurge(MyHand);            /* Mark handle as purgeable */
}

Word getSoundID(Word SoundNum)
{
    if (SoundNum) {
        SoundNum+=127;
        return SoundNum&0x7fff;
    }
    return -1;
}

void PlaySound(Word SoundNum)
{
    if (SoundNum) {
        SoundNum+=127;
        if (SoundNum&0x8000) {        /* Mono sound */
            EndSound(SoundNum&0x7fff);
        }
        BeginSound(SoundNum&0x7fff,11127<<17L);
    } else {
        EndAllSound();
    }
}

//MW specified argument and return type.
int main(void)
{
    short int *SoundListPtr;
    Byte * bites;
    long len;
    FILE *fptr;
    
    //Initialize();
    
    InitSoundMusicSystem(8,8,5,jxLowQuality);
    //PurgeSongs(TRUE);            /* Allow songs to stay in memory */
    SoundListPtr = (short int *) LoadAResource(MySoundList);    /* Get the list of sounds */
    RegisterSounds(SoundListPtr,FALSE);
    ReleaseAResource(MySoundList);            /* Release the sound list */
    
    PlaySound(SND_OPENDOOR);
    
    bites = GetSoundWaveform(getSoundID(SND_OPENDOOR));
    
     len = GetSoundLength(getSoundID(SND_OPENDOOR));
     fptr = fopen("SND_OPENDOOR", "w");
     fwrite(bites, 1,len, fptr);
     fclose(fptr);
    
    /*
Byte *        GetSoundWaveform(short int theID);
long        GetSoundLength(short int theID);
long        GetSoundDefaultRate(short int theID);
long        GetSoundLoopStart(short int theID);
long        GetSoundLoopEnd(short int theID);
*/
    do {} while (!Button());
    
    FinisSoundMusicSystem();
    
    //do {
    //    NewBall();
    //} while (!Button());

    return 0;    
}

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Post Reply