Music-Output

Joerg Polzfusz (pilz@cs.tu-berlin.de)
Wed, 2 Oct 1996 23:13:52 +0200 (MET DST)

-----BEGIN PGP SIGNED MESSAGE-----

Hello!
Since some of you seem to deal with midi-output, too, I'm writing this
eMail:
Yes, midi-output under Geos looks easy since the midi-format is pretty much
the same as the fm-sound-format used by Geos and the instruments are
already pre-defined. Thus I bought a book with a better description of the
midi-format, wrote test-proggies, ... .
But: I'm not the first programmer who wasn't able to use more than one
voice. This is due to the lack of information on the sdk-cd. And even worse:
the sdk-docu contradicts itself!

If you want to play with it, too, try this program (WARNING:
Execution=>Geos hangs up!) (Maybe you should try it on two PCs (haven't done
it yet).) (Please use your own IDs!):
- ----------------Part 1: stest.goc:---------------------------
/*Soundtestproggi "works" as written in the docu.*/
@include "stest.goh"

MemHandle theSong;
const word themeSongBuf[] = {
SSE_CHANGE, MELODY, IP_FLUTE,
SSE_CHANGE, PERC, IP_ACOUSTIC_SNARE,
SSE_GENERAL, GE_SET_PRIORITY, SP_GAME,
SSE_VOICE_ON, PERC, FR_ACOUSTIC_SNARE, DYNAMIC_F,
SSDTT_TEMPO, QUARTER,
SSE_VOICE_OFF, PERC,
SSE_VOICE_ON, PERC, FR_ACOUSTIC_SNARE, DYNAMIC_F,
SSDTT_TEMPO, EIGHTH,
SSE_VOICE_OFF, PERC,
SSDTT_TEMPO, EIGHTH,
SSE_VOICE_ON, PERC, FR_ACOUSTIC_SNARE, DYNAMIC_F,
SSE_VOICE_ON, MELODY, LOW_C, DYNAMIC_MP,
SSDTT_TEMPO, QUARTER,
SSE_VOICE_OFF, PERC,
SSE_CHANGE, PERC, IP_COWBELL,
SSE_VOICE_ON, PERC, FR_COWBELL, DYNAMIC_F,
SSDTT_TEMPO, EIGHTH,
SSE_VOICE_OFF, PERC,
SSDTT_TEMPO, EIGHTH,
SSE_VOICE_OFF, MELODY,
SSDTT_TICKS, 120,
SSE_GENERAL, GE_END_OF_SONG};

/*****************************************************************/

@class stestProcessClass, GenProcessClass;
@message void MSG_STEST_PLAY_IT();
@endc

@classdecl stestProcessClass, neverSaved;

/*****************************************************************/

@start AppMonikerResource, data;

@visMoniker TextMoniker = "Soundtest";

@end AppMonikerResource

/*****************************************************************/

@start AppResource;

@object GenApplicationClass stestApp =
{
GI_visMoniker = list {@stTextMoniker}
GI_comp = @stPrimary;
gcnList(MANUFACTURER_ID_GEOWORKS,GAGCNLT_WINDOWS) = @stPrimary;
}

@visMoniker stTextMoniker = "Soundtest";

@end AppResource;

/*****************************************************************/

@start Interface;

@object GenPrimaryClass stPrimary =
{
GI_comp = @stText, @stPlayTrigger, @stOutput;
HINT_SIZE_WINDOW_AS_DESIRED;
HINT_CENTER_CHILDREN_HORIZONTALLY;
}

@object GenValueClass stOutput = {
GI_visMoniker = "Errorcode:";
GVLI_displayFormat = GVDF_INTEGER;
GVLI_value = MakeWWFixed(0.0);
HINT_VALUE_NOT_INCREMENTABLE;
HINT_VALUE_DIGITAL_DISPLAY;
HINT_VALUE_NOT_DIGITALLY_EDITABLE;
}

@visMoniker StdTextMoniker = "This button plays some music.";
@visMoniker Err1TextMoniker = "Error #1!";
@visMoniker Err2TextMoniker = "Error #2!";
@visMoniker Err3TextMoniker = "Error #3!";

@object GenGlyphClass stText =
{
GI_visMoniker = StdTextMoniker;
}

@object GenTriggerClass stPlayTrigger =
{
GI_visMoniker = 'P',"Play it";
GTI_destination = process;
GTI_actionMsg = MSG_STEST_PLAY_IT;
}

@end Interface;

/*****************************************************************/
@method stestProcessClass, MSG_GEN_PROCESS_OPEN_APPLICATION
{
@callsuper();
/* SoundGetExclusive();*/
if (SoundAllocMusic(themeSongBuf, 2, &theSong))
@call stText::MSG_GEN_USE_VIS_MONIKER(OptrToChunk(@Err2TextMoniker),
VUM_DELAYED_VIA_UI_QUEUE);
}

@method stestProcessClass, MSG_STEST_PLAY_IT
{ word erg;
if (theSong) {
/* SoundGetExclusive();*/
erg=SoundPlayMusic(theSong, SP_SYSTEM_LEVEL+SP_IMMEDIATE, 125, 0);
/* SoundReleaseExclusive();*/
if (erg) {
@call stText::MSG_GEN_USE_VIS_MONIKER(OptrToChunk(@Err3TextMoniker),
VUM_DELAYED_VIA_UI_QUEUE);
@call stOutput::MSG_GEN_VALUE_SET_INTEGER_VALUE(erg,FALSE);
};
}
else @call stText::MSG_GEN_USE_VIS_MONIKER(OptrToChunk(@Err1TextMoniker),
VUM_DELAYED_VIA_UI_QUEUE);
}

@method stestProcessClass, MSG_GEN_PROCESS_CLOSE_APPLICATION
{
SoundStopMusic(theSong);
SoundFreeMusic(theSong);
/* SoundReleaseExclusive();*/
return(@callsuper());
}

- ---------------------Part 2: stest.goh:-------------------------------
@include <stdapp.goh>
@include <geomisc.h>
@include <gstring.h>
@include <geode.h>
@include <system.h>
@include <grobj.goh>
@include <sound.h>

#define MELODY 0
#define PERC 1

- -----------------------Part 3: stest.gp:-------------------------------
###############################################################################
# Written by Joerg Polzfusz 25.07.96 #
# PROJECT : Program for Geoworks 2.0 #
# MODULE : stest #
# FILE : stest.gp #
# DESCRIPTION: Tests the sound-capatibilities #
###############################################################################

#Permanent Name #
name stest.app
###############################################################################

#Long Name #
longname "Soundtest"

type appl, process, single

class stestProcessClass

appobj stestApp

tokenchars "st01"

tokenid 16457
#PLEASE USE YOUR OWN ID!!!!!!!#

resource APPRESOURCE ui-object
resource INTERFACE ui-object

library geos
library ui
library ansic
library sound

- -----------------------THE END!--------------------------------------
In a hurry
Joerg
- --
,,,,
(.)-(.)
- ------------------------------------oOO-(_)-OOo--------------------------------
pilz@cs.tu-berlin.de
http://www.cs.tu-berlin.de/~pilz/
- -------------------------------------------------------------------------------

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: latin1

iQBVAwUBMlLbDeINOQrPy47dAQFkCgIApYN81TNvzBQCjIfNzQts2vK2QtFI2WOe
W6e4jrj3IWiXyKcBSX0gOnrMtlHmkT3lvKlt5DQbCOEIDf5FWXbJ7Q==
=zbQa
-----END PGP SIGNATURE-----