Sound Editor again!

Joakim Hi all! A new version with loads of fixes (but mostly under the hood) has been uploaded to; http://beta.visualagi.cjb.net The file is called "vagi_se3.zip". Most noticable changes; * Can now export resources to MIDI. (it's pretty good at it, too! ;) * Can now edit the NOISE-channel (yeeha). It doesn't play it yet though, so you'll be working in the dark.. I have also changed some compilation flags, so that it _might_ (but I don't know) work under Windows 95. Happy editing, nevertheless! / Joakim
Joel Ok, now that I've gotten some idea how to use the thing, I figured I'd give it a go making a test sound resource to be added to a game. The thing plays fine in the Sound Editor and I can export it and reimport it and it still works, but for some reason it won't play when I add it to an AGI game using the Sierra interpreter. NAGI plays the sound, but the silence note that's added for an empty voice is interpreted as a really loud annoying noise by NAGI (by design, I think -- if I remember correctly, NAGI does the sound volume in reverse because so many fan games have it wrong). Wouldn't it be possible to just leave that long silence note out and just make the empty voices empty? And, of course, the obvious question, any idea why it might not be playing the sound? The sound resource reading code I wrote a few months ago can read the file that's exported by the vAGI sound editor fine (that's how I knew about the really long note and didn't just think NAGI was going nuts), so as far as I can tell the sound resource is not corrupted or anything. I made a 2 voice sound resource -- I'm going to try a 1 voice and see if it fares any better.
Joel a one-voice song won't play, either
sonneveld There's a sound variable that the intepreter defines as the overal volume. That's the value that's wrong in most games. Whether it's adhered to or not depends on the setting in nagi.ini

As far as i know.. the volume settings taken from the sound files are played correctly.

Remember, in AGI, the volume is actually called attenuation.. which is a value subtracted from the max volume. So 0xF is silence. 0 is max. Later versions of the interpeter incorporate an envelope too so sounds will fade off.

I hope that helps.

Joakim: have you managed to look at NAGI's sound code and incorporate any of it in Visual AGI?

- Nick
Joakim
Joel wrote:

Ok, now that I've gotten some idea how to use the thing, I figured I'd give it a go making a test sound resource to be added to a game. The thing plays fine in the Sound Editor and I can export it and reimport it and it still works, but for some reason it won't play when I add it to an AGI game using the Sierra interpreter. NAGI plays the sound, but the silence note that's added for an empty voice is interpreted as a really loud annoying noise by NAGI (by design, I think -- if I remember correctly, NAGI does the sound volume in reverse because so many fan games have it wrong). Wouldn't it be possible to just leave that long silence note out and just make the empty voices empty? And, of course, the obvious question, any idea why it might not be playing the sound? The sound resource reading code I wrote a few months ago can read the file that's exported by the vAGI sound editor fine (that's how I knew about the really long note and didn't just think NAGI was going nuts), so as far as I can tell the sound resource is not corrupted or anything. I made a 2 voice sound resource -- I'm going to try a 1 voice and see if it fares any better.


Actually, I haven't tried exporting resources and using them in a game yet. I will look into that later today. Have you tried importing an AGI resource (such as kq1.000), exporting it, and including it to a game? If that breaks the music play, something is possible wrong in the code.

About the off-notes in empty channels, I cannot recall why I ever put them there. ;) I will see if I can change my routines to eliminate them. (what I call an off-note is actually A#9 with attenuation 15, silent)

The issue with NAGI is rather strange though. As the off-note _should_ have attenuation 15 (if I haven't made a typo somewhere in the code), NAGI shouldn't play those notes at all.

/ Joakim
Joakim
Nick Sonneveld wrote:

Joakim: have you managed to look at NAGI's sound code and incorporate any of it in Visual AGI?


No, not at the moment. Some day I will rewrite the sound player, as it is very buggy and have a high latency (around 500 ms).. What I would like to "borrow" from your code is the envelope on notes, and the noise code.

Right now I also play directly from my own data resources using a separate thread. I would like to rewrite the sound playing thread so that it is more general, perhaps even distributable for other people that would like to use DirectSound for their projects.

/ Joakim
Joakim I did some research in the files exported by Visual AGI, and found some major errors. I haven't got the code here at work, so I can't fix it until tonight. It also affects the export of MIDI files, as it contains part of the code from the AGI export.

The error is most noticable in for example sound 60 in Space Quest 1. The export routine accidentally uses the NEXT note's attenuation value, instead of the one it should use.. Hehe. Try to export sound 60 to midi and listen to it, quite interesting I think.. ;)

Also, I found a slight irregulance on empty channels. When I export, I set the PCjr register channel on the frequency bit even though the channel is empty, but the real Sierra resources simply puts an empty byte as the frequency. In SQ1, it doesn't even put an empty note in unused channels, instead it just ends the channel directly. Does anyone know which way is the most correct?

Nevertheless, I would advise you not to use the export function until I release an updated version.

/ Joakim
sonneveld my sound script utils were meant to help in these situations. That way you wouldn't have to worry about generating correct sound files, just to generate a correct script file.

- Nick
Joel Hmmm...I modified my sound resource reading code to print out the attenuation as well, and it seems to me that when I don't explicitly set the attenuation for the notes, then they get the correct attenuation (I think I did notice something about them getting the next note's attenuation when I explicitly set the attenuation). Once thing I did notice is that the long silence note for the noise channel has an attenuation of 0, whereas the others have an attenuation of 15. Here's the output of my code for a simple sound resource exported from the vAGI Sound Editor.

Adding note C 5 with duration 7; attenuation: 0; note type: 16th
Adding note rest with duration 7; attenuation: 15; note type: 16th
Adding note D 5 with duration 7; attenuation: 0; note type: 16th
Adding note rest with duration 7; attenuation: 15; note type: 16th
Adding note E 5 with duration 7; attenuation: 0; note type: 16th
Adding note rest with duration 7; attenuation: 15; note type: 16th
Adding note F 5 with duration 7; attenuation: 0; note type: 16th
Adding note rest with duration 7; attenuation: 15; note type: 16th
Adding note G 5 with duration 7; attenuation: 0; note type: 16th
Adding note rest with duration 7; attenuation: 15; note type: 16th
Adding note A 5 with duration 7; attenuation: 0; note type: 16th
Adding note rest with duration 7; attenuation: 15; note type: 16th
Adding note B 5 with duration 7; attenuation: 0; note type: 16th
Adding note rest with duration 7; attenuation: 15; note type: 16th
Adding note C 6 with duration 7; attenuation: 0; note type: 16th
Adding note rest with duration 7; attenuation: 15; note type: 16th
End of voice

Adding note rest with duration 112; attenuation: 15; note type: whole
End of voice

Adding note rest with duration 112; attenuation: 15; note type: whole
End of voice

Adding note rest with duration 112; attenuation: 0; note type: whole
End of voice


Of course the note type of whole for those empty voices is way off. It's just the closest estimate that I wrote into my code for a super-long note.
Joel ok, actually, the whole note estimate is right in this case, I think, but it's wrong if the notes have a duration of 1000. Anyway, not the point of what I'm saying so I guess it's not important.
Joakim Finally!

I managed to nail down the (hopefully?) last major bugs with the export code. It was actually a very simple error to fix, but it caused big damage with the attenuations.

I also fixed a little bonus for you all in the MIDI export. Try it out! ;)

Oh, you can also set the step size, bpm and tpb now!

Find it as usual on !!

/ Joakim
Joel the new stuff you added looks pretty cool.

there's another scrollbar issue -- when you change the step size and it causes the end of song marker to be moved off screen, no scrollbar appears to take you down to it. Again, scrolling down with the keyboard causes scrollbars to appear.

As for exporting: the loud, annoying tone no longer sounds in NAGI, and the sound resources appear to work fine with it. However, they still will not play with the Sierra interpreter.
Joakim
Joel wrote:

there's another scrollbar issue -- when you change the step size and it causes the end of song marker to be moved off screen, no scrollbar appears to take you down to it. Again, scrolling down with the keyboard causes scrollbars to appear.


I'll look into that!


As for exporting: the loud, annoying tone no longer sounds in NAGI, and the sound resources appear to work fine with it. However, they still will not play with the Sierra interpreter.


Hmm. That's strange. Are you sure that nothing is wrong with your PC speaker? :)

Enough irony, could you send me the exported resource, so that I can investigate it? I cannot reproduce your problem, at least not with the interpreter from KQ1. I will try some other interpreters as well.

/ Joakim
Joel I was about to send you the exported resource when I decided to do another test. Originally, I was running the sounds out of a test game that I had created to test the Base Logic Generator. I created that game from the template that comes with AGI Studio 1.35. I decided to run the game with the interpreter I zipped up to distribute from my old website, and the sound works.

The interpreter I use with Jen's Quest (and which was in the zip file) is interpreter version 2.917. The sounds work fine from that one.

The interpreter that I was using with the test game was interpreter version 2.936. The sounds don't play in that interpreter.
Joel and yet another test reveals that the problem seems to be specific to the version 2.936 interpreter that ships with AGI Studio 1.35, and I've also found that sounds NOT created with the vAGI Sound Editor will also not play with that interpreter. Is the template game's interpreter hacked in any way? I just downloaded the 2.936 interpreter from Nick's site, and the sound works fine there, too.
Joakim
Joel wrote:

and yet another test reveals that the problem seems to be specific to the version 2.936 interpreter that ships with AGI Studio 1.35, and I've also found that sounds NOT created with the vAGI Sound Editor will also not play with that interpreter. Is the template game's interpreter hacked in any way? I just downloaded the 2.936 interpreter from Nick's site, and the sound works fine there, too.


Ah. What a fortune that it wasn't my fault this time.. ;)

/ Joakim
sonneveld I think Chris has patched it. My guess is the joystick patch to help joysticks on faster computers. I did a file compare and the one in the template differs in a few sections (so not just the game id)

- Nick