Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: Elliott Lee Newsgroups: scee.yaroze.beginners Subject: Re: Sound Probs. (long reply) Date: Thu, 26 Feb 1998 15:03:27 -0800 Organization: . Lines: 132 Message-ID: <34F5F4BF.B70199D2@netmagic.net> References: <34F5E3F3.41C6@bournemouth.ac.uk> Reply-To: tenchi@netmagic.net NNTP-Posting-Host: dhcp-e-39-245.cisco.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.03 [en] (Win95; U) Anna wrote: > > I'm having a few problems getting any sound happenning. I've converted > a single .wav (16 bit, uncompressed, mono) with aiff2vag, and then > (attempted) to make a vab file, seperated into vh & vb. But when I > attempt to play this with SsUtKeyOn nothing happens, and -1 is returned > (so I guess SsUtKeyOn failed). > > Is it necessary to have a SEQ file, even though I only want to play one > sound effect at a time? I've set the volume using SsSetMVol, but in the > sample pieces of code I've looked at, they've also used SsSetSeqVolume. > I haven't used this as I have no SEQ file. > > I'm also confused about the use of the def file when making the .vab. is > there an easy way to make the def file? I ask this because I'm not sure > where you're supposed to get the values for the center and shift labels > in the ToneAtr. I've just sampled a single sound effect from a CD so I > have no idea what note it's supposed to be. Because of this I just > bunged in any old values, would this adversly affect things if I got it > wildly wrong? > > Cheers, Anna. Yeah, sound is tricky at first. The general order of things in your code should be: 1) transfer the sound data from local RAM to the sound RAM w/ SsVabTransfer() 2) set the master volume 3) begin playing sounds 4) stop the sound playback in the sequencer and call SsUtAllKeyOff() when you exit First of all, no, you don't need to have a SEQ file to play sound. I have a VAB in memory that has all the sound effects and then I just SsUtKeyOn() when I want some of them to play. Second, when you did the SsVabTransfer(), did you make sure that you got a VAB ID back and not an error message? Make sure you loaded your VAB into a region of memory that won't conflict with anything else. Your code, by default, goes into 0x80100000. If you look at the sample programs, you may see that the general MIDI set gets loaded in at 0x80090000 and 0x800a0000. That's just above the 572K system library stuff and just below your code. That area is great for sound. Third, are you sure you created your VAB correctly? You got the VAGs from the AIFF2VAG utility---good. You gotta make sure your DEF file is correct. If you don't format that thing right, you'll get a corrupted one back out. What I do is to check it: 1) use mkvab to make your VAB 2) call it again: mkvab -r -o debug.def 3) compare your original .DEF to the DEBUG.DEF file. If they match, you did it right. If not, check your syntax. The mkvab util is picky about the way you specify things. Remember that a VAB is a collection of VAGs. Each VAG is the wave form. A def file describes how the VAGs are combined to form an "instrument". For example, a simple sound effect would have 1 VAB "program" and one VAG "tone". A more complex multi-layer instrument (e.g. piano + strings) would still have 1 VAB program but 2 VAG tones. The most complex example is probably General MIDI instrument 128: the drum set. I'm not exactly sure how this is implemented on the Yaroze, but for MIDI keyboards each key is mapped to a separate tone. That's why if you put your full drum track to use instrument 128 C2 gets you a bass drum, E2 gets you a snare, A#/Bb a hi-hat, etc. When making your DEF file, just don't throw in any value---they WILL affect the playback! The shift value 0 is probably good, and the center should probably be 64 (dead center stereo panning; 0 would be extreme left and 127 extreme right). Lastly, the "note" argument to SsUtKeyOn is the MIDI key. Each key on the keyboard is assigned a number, 48 being Middle C (C4), 36 being an octave lower (C3), etc. Remember that the musical scale has 12 semi-tones per octave: Note# Name Octave ... 45 A 3 46 A# / Bb 3 47 B 3 48 C 4 49 C# / Db 4 50 D 4 51 D# / Eb 4 52 E 4 ... Most MIDI devices respond to something like keys 12-70---anything beyond that gets ridiculously low or high. If you have a sound and want it to play back at the same speed (pitch) you recorded it at, use Middle C (48). If you grab the updated PDF Yaroze manuals, they have a sample DEF file in there. One note: I found that I got errors if I didn't put a blank line between each of the entries in the DEF file. I think I've got sound down pat (almost). I can upload/e-mail a simple example of how this all works. There is a sound example on SCEA, but I didn't find it that easy to follow. :( I hope this is confusing enough, :P - e! tenchi@netmagic.net http://www.netmagic.net/~tenchi/yaroze/