Thread View: net.micro.mac
1 messages
1 total messages
Started by Martin Taylor
Mon, 17 Dec 1984 15:52
music.pas transliterated into C
Author: Martin Taylor
Date: Mon, 17 Dec 1984 15:52
Date: Mon, 17 Dec 1984 15:52
193 lines
6344 bytes
6344 bytes
For fun, I transliterated Andrew Shebanow's MacPascal 4-voice
synthesizer program into C for SUMacC. It provides an example
of how to specify waveshapes and to run the 4-voice sound.
==================Cut Here================
/*********************************************************************/
/* Plays a simple tune using the four voice capabilities of the Mac */
/* Written By: Andrew G. Shebanow 10/25/84 */
/* Tune "converted" by John Hewitt & Andrew Shebanow shebanow@ucbernie */
/* Transliterated into SUMacC C by Martin Taylor: */
/* utcsrgv!dciem!mmt@uw-beaver.arpa */
/*********************************************************************/
#include "mac/quickdraw.h"
#include "mac/osintf.h"
long Note32nd = 3; /* multiply factors for the duration of... */
long Rest32nd = 1; /* the note and the rest */
/* constants for note values from "Inside Macintosh" */
long NoNote = 0; /* for unused voices */
long Down1E = 124376;
long Down1Gb = 141525;
long Down1Ab = 159201;
long Down1A = 165834;
long Down1B = 186564;
long MidD = 223877;
long MidE = 248752;
long MidAb = 318403;
long MidA = 331669;
long MidBb = 348253;
long MidB = 373128;
long Up1Db = 424537;
long Up1D = 447754;
long Up1E = 497504;
long Up1Gb = 566100;
long Up1Ab = 636806;
long Up1A = 663339;
long Up1B = 746257;
long Up2Db = 849074;
Wave wave1, wave2; /* the sound wave */
SoundStruct sndRec; /* the four voice sound record */
/* InitWaves initializes the sound wave shape */
InitWaves()
{
int j;
for (j=0; j<=31; j++)
{
wave1.s[j] = 0;
wave2.s[j] = 0;
}
for (j=32; j<=63; j++)
{
wave1.s[j] = 60;
wave2.s[j] = 10;
}
for (j=64; j<=191; j++)
{
wave1.s[j] = 250;
wave2.s[j] = 70;
}
for (j=192; j<=224; j++)
{
wave1.s[j] = 60;
wave2.s[j] = 10;
}
for (j=225; j<=255; j++)
{
wave1.s[j] = 0;
wave2.s[j] = 0;
}
}
/* InitSounds initializes the sound structures */
InitSounds()
{
/* InitSounds */
InitWaves();
sndRec.snd1Wave = &wave1;
sndRec.snd2Wave = &wave2;
sndRec.snd3Wave = &wave2;
sndRec.snd4Wave = &wave2;
sndRec.snd1Phase = 0;
sndRec.snd2Phase = 0;
sndRec.snd3Phase = 0;
sndRec.snd4Phase = 0;
}
/* Rest is a delay loop which does the proper delay for a note*/
Rest(n)
int n;
{
long ticks;
ticks = TickCount() + (Rest32nd * n);
while (ticks >= TickCount())
;
}
/* Play is the workhorse of the program. It plays a single 4 voice */
/* chord of the given duration using the four notes specified */
Play (note1, note2, note3, note4, n32nds)
long note1, note2, note3, note4;
int n32nds;
{
int length;
length = n32nds * Note32nd;
sndRec.duration = length;
sndRec.snd1Rate = note1;
sndRec.snd2Rate = note2;
sndRec.snd3Rate = note3;
sndRec.snd4Rate = note4;
StartSound((Ptr)&sndRec);
Rest(1);
}
/* Note that this tune is in 3/4 time. */
Part1()
{
Play(NoNote, MidE, NoNote, NoNote, 8); /* Measure 0 */
Play(Down1E, MidAb, Up1Db, NoNote, 6); /* Measure 1 */
Play(NoNote, Up1D, NoNote, NoNote, 2);
Play(NoNote, MidD, MidAb, MidB, 8);
Play(Down1B, MidD, MidAb, MidB, 8);
Play(Down1E, MidD, MidAb, MidB, 16); /* Measure 2 */
Play(NoNote, Up1D, Up1Gb, NoNote, 8);
Play(NoNote, MidB, Up1D, NoNote, 4); /* Measure 3 */
Play(NoNote, Up1Db, Up1E, NoNote, 4);
Play(Down1A, Up1Db, Up1E, Up1A, 8);
Play(Down1E, Up1Db, Up1E, Up1A, 8);
Play(Down1A, Up1Db, Up1E, Up1A, 16); /* Measure 4 */
Play(NoNote, Up1Db, NoNote, NoNote, 8);
Play(Down1E, MidBb, NoNote, NoNote, 6); /* Measure 5 */
Play(NoNote, MidB, NoNote, NoNote, 2);
Play(Down1B, Up1D, NoNote, NoNote, 8);
Play(Down1B, Up1D, NoNote, NoNote, 8);
}
Part2()
{
Play(Down1Ab, Up1D, NoNote, NoNote, 8); /* Measure 6 */
Play(Down1E, Up1D, NoNote, NoNote, 8);
Play(Down1B, MidAb, NoNote, NoNote, 8);
Play(Down1E, MidAb, NoNote, NoNote, 6); /* Measure 7 */
Play(NoNote, MidA, NoNote, NoNote, 2);
Play(Down1A, MidA, Up1Db, NoNote, 8);
Play(Down1E, MidA, Up1Db, NoNote, 8);
Play(Down1A, MidA, Up1Db, NoNote, 16); /* Measure 8 */
Play(NoNote, MidE, NoNote, NoNote, 8);
Play(Down1E, MidAb, Up1Db, NoNote, 6); /* Measure 9 */
Play(NoNote, Up1D, NoNote, NoNote, 2);
Play(NoNote, MidD, MidAb, MidB, 8);
Play(Down1B, MidD, MidAb, MidB, 8);
Play(Down1E, MidD, MidAb, MidB, 16); /* Measure 10 */
Play(NoNote, Up1D, Up1Gb, NoNote, 8);
Play(NoNote, MidB, Up1D, NoNote, 6); /* Measure 11 */
Play(NoNote, Up1Db, Up1E, NoNote, 2);
Play(Down1A, Up1E, Up1A, Up2Db, 8);
Play(Down1E, Up1E, Up1A, Up2Db, 8);
}
Part3()
{
Play(NoNote, Up1E, Up1A, Up2Db, 8); /* Measure 12 */
Play(Down1Gb, NoNote, NoNote, NoNote, 8);
Play(NoNote, MidE, MidA, Up1Db, 8);
Play(Down1Gb, MidA, Up1Db, NoNote, 6); /*Measure 13 */
Play(NoNote, MidB, Up1D, NoNote, 2);
Play(Down1B, MidB, Up1D, Up1Gb, 8);
Play(Down1A, MidB, Up1D, Up1Gb, 8);
Play(Down1Ab, MidB, Up1D, Up1Gb, 16); /* Measure 14 */
Play(Down1E, MidB, Up1D, Up1Ab, 8);
Play(Down1E, Up1D, Up1E, Up1B, 6); /* Measure 15 */
Play(NoNote, Up1A, NoNote, NoNote, 2);
Play(Down1A, Up1Db, Up1E, Up1A, 8);
Play(Down1E, Up1Db, Up1E, Up1A, 8);
Play(Down1A, Up1Db, Up1E, Up1A, 16); /* Measure 16 */
Rest(8);
}
main()
{ /* Sound */
InitSounds();
Part1();
Part2();
Part3();
}
==========================================
--
Martin Taylor
{allegra,linus,ihnp4,floyd,ubc-vision}!utzoo!dciem!mmt
{uw-beaver,qucis,watmath}!utcsrgv!dciem!mmt
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads