Path: chuka.playstation.co.uk!news From: Developer Support Newsgroups: scea.yaroze.programming.sound Subject: Re: Which function Plays Sound effects? Date: Mon, 14 Jul 1997 11:07:26 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 283 Message-ID: <33C9FA5E.6EDE@interactive.sony.com> References: <33C360ED.3922@cobradev.demon.co.uk> <33C4A88F.6A7@interactive.sony.com> <33C9A08B.834@dfwmm.net> NNTP-Posting-Host: 194.203.13.10 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.01 (Win95; I) OK, I've sorted out an example, it works with siocons, I'll put it in the demos area aswell. Just cut and paste to use. Here goes Stuart --------------------- the batch file (name 'batch')------------------ local dload 80100000 local dload 80140000 local dload 80160000 local load main --------------------- the make file (name 'makefile')----------------- CFLAGS = -O2 -g LINKER = -Xlinker -Ttext -Xlinker 80090000 RM = del PROG = main OBJS = main.o all: $(PROG) $(PROG): $(OBJS) $(CC) $(OBJS) $(LINKER) -o $(PROG) main.o: main.c clean: $(RM) $(PROG) $(RM) $(OBJS) .PHONY: all load clean --------------------- the program file (name 'main.c') --------------- /*************************************************************** * * * Copyright (C) 1997 by Sony Computer Entertainment * * All rights Reserved * * * * S. Ashley 14th Jul 97 * * * ***************************************************************/ #include // VAB and sequence location #define VH0_ADDR 0x80140000L #define VB0_ADDR 0x80160000L #define SEQ_ADDR 0x80100000L // pad stuff #define PADLup (1 <<12) #define PADLdown (1 <<14) #define PADLleft (1 <<15) #define PADLright (1 <<13) #define PADRup (1 << 4) #define PADRdown (1 << 6) #define PADRleft (1 << 7) #define PADRright (1 << 5) #define PADstart (1 <<11) #define PADselect (1 << 8) short vab0; short seq1; char finish; // pad buffers volatile u_char *bb0, *bb1; void padControl(void); int programToneAvailable(u_short *VHAddr, u_short prog, u_short tone); main (void) { finish = 0; // set up pad buffers GetPadBuf(&bb0, &bb1); ResetGraph(0); printf("******************************************************\n"); printf("* PADLleft - play note PADLright - stop all notes *\n"); printf("* PADRup - prog + PADRdown - prog - *\n"); printf("* PADRleft - tone - PADRright - tone + *\n"); printf("* PADLup - play the lot PADLdown - stop play *\n"); printf("* PADSelect - pause PADStart - continue *\n"); printf("* PADSelect & PADStart - end *\n"); printf("******************************************************\n"); // transfer VAB data vab0 = SsVabTransfer((u_char *)VH0_ADDR, (u_char *)VB0_ADDR, -1, 1); if (vab0 < 0) { printf("VAB open failed\n"); exit(1); } // transfer sequence data seq1 = SsSeqOpen((u_long *)SEQ_ADDR, vab0); if (seq1 < 0) { printf("SEQ open failed\n"); } SsSetMVol(127, 127); SsSeqSetVol(seq1, 127, 127); SsSeqPlay(seq1, SSPLAY_PLAY, 0); printf("\nprog 0 tone 0"); do { VSync (0); padControl(); } while (!finish); SsSeqClose(seq1); // close sequence and VAB SsVabClose(vab0); } // *** controls *** void padControl(void) { static unsigned long opad; static short voice1; static short voice2; static char prog; static char tone; static char allPlay = 0; static int autoPlayPause = 0; u_long pad; // pad read pad = ~(*(bb0+3) | *(bb0+2) << 8 | *(bb1+3) << 16 | *(bb1+2) << 24); // next tone (part of current program) if ((pad & PADRright) && !(opad & PADRright)) { do if (++tone > 15) tone = 0; while (!programToneAvailable((u_short *)VH0_ADDR,prog,tone)); printf("\nprog %d tone %d",prog,tone); } // previous tone (part of current program) if ((pad & PADRleft) && !(opad & PADRleft)) { do if (--tone > 15) tone = 15; while (!programToneAvailable((u_short *)VH0_ADDR,prog,tone)); printf("\nprog %d tone %d",prog,tone); } // next program if ((pad & PADRup) && !(opad & PADRup)) { tone = 0; do if (++prog < 0) prog = 0; while (!programToneAvailable((u_short *)VH0_ADDR,prog,tone)); printf("\nprog %d tone %d",prog,tone); } // previous program if ((pad & PADRdown) && !(opad & PADRdown)) { tone = 0; do if(--prog < 0) prog = 127; while (!programToneAvailable((u_short *)VH0_ADDR,prog,tone)); printf("\nprog %d tone %d",prog,tone); } // play each sound in turn from the beginning if ((pad & PADLup) && !(opad & PADLup)) { prog = 0; tone = 0; allPlay = 1; } // stop playing sounds in turn if ((pad & PADLdown) && !(opad & PADLdown)) { allPlay = 0; autoPlayPause = 0; } // bit that does the playing of all the sounds if (allPlay) { if (autoPlayPause == 0) { printf("\nprog %d tone %d", prog, tone); voice2 = SsUtKeyOn(vab0, prog, tone, 60, 0, 127, 127); autoPlayPause = VSync(-1); } if (VSync(-1) - autoPlayPause > 80) { SsUtKeyOff(voice2, vab0, prog, tone, 60); do if (++tone > 15) { tone = 0; if (++prog < 0) prog = 0; } while (!programToneAvailable((u_short *)VH0_ADDR, prog, tone)); autoPlayPause = 0; } } // play current sound (key hit) if ((pad & PADLleft) && !(opad & PADLleft)) voice1 = SsUtKeyOn(vab0, prog, tone, 60, 0, 127, 127); // and stop playing current sound (key release) if (!(pad & PADLleft) && (opad & PADLleft)) SsUtKeyOff(voice1, vab0, prog, tone, 60); // stop playing all sounds if ((pad & PADLright) && !(opad & PADLright)) SsUtAllKeyOff(0); // pause sequence if ((pad & PADselect) && !(opad & PADselect)) SsSeqPause(seq1); // resume sequence if ((pad & PADstart) && !(opad & PADstart)) SsSeqReplay(seq1); // quit if ((pad & PADselect) && (pad & PADstart)) { SsSeqStop(seq1); finish = 1; } opad = pad; } // *** function to check the availability of a particular program and tone *** int programToneAvailable(u_short *VHAddr, u_short prog, u_short tone) { u_short numProg = *(VHAddr + 9); u_long t; u_long i = 0; // check tone is within limits and programs exist if (numProg == 0 || tone > 15) return 0; // check program is connected to tone do t = (u_long)VHAddr + 2080L + 512L * i + 20; while (i++ < numProg && *(u_short *)t != prog); if (*(u_short *)t != prog) return 0; // check tone connected to sound t = (u_long)VHAddr + 2080 + 512 * --i + 32 * tone + 22; if (*(u_short *)t > 0) return 1; else return 0; }