Sound driver fun

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
User avatar
Augustus Blackheart
Posts: 61
Joined: Sat Jul 26, 2014 9:50 am

Sound driver fun

Post by Augustus Blackheart »

What's new:
Added driver "Celes" which has a version of psychopathicteen's fm code, whichever old version was posted here. This song (mp3|spc) uses an earlier version of the driver.

Celes repurposes IT commands for other features. I really should get around to adding SPC playback into schismtracker.
Current smconv :: all source with Celes, Pitchmod, SNESMod, and Super SNESMod NoFX drivers. (updated December 2017:: no Windows binary yet.)

11 songs
Attachments
tremolo-test.sfc
Tremolo test
(128 KiB) Downloaded 271 times
supersnesmod.sfc
Example ROM
(256 KiB) Downloaded 281 times
Last edited by Augustus Blackheart on Sat Dec 16, 2017 8:52 am, edited 45 times in total.
KungFuFurby
Posts: 275
Joined: Wed Jul 09, 2008 8:46 pm

Re: Sound driver fun

Post by KungFuFurby »

Filesize-wise, I kept everything below 5632 bytes. Anything bigger, and you're forced to modify the SNESMod compiler application and the source code to deal with the change (I stopped just 10 bytes short of having to do this)... and for me, I wanted to just simply implant the code using a hex editor.

The glitch that I mentioned deals with noise generation and SFX (pitch modulation might technically count, too).

I really don't like the idea of overwriting existing IT tracker effects (that makes things worse for me to test when composing in Schism Tracker, as I have no way to disable those effects, which means my pre-conversion testing can seriously get hampered). I prefer either unused effects in Impulse Tracker (either that, or I prefer implementing the original effects)... I did S0x-S3x for that reason, and I did S9x, too.

I actually had the following ideas for extra features (from 2013, actually), but I stopped short because I would have to modify the compiler source code to reallocate the module files due to memory consumption (and some of these are brand new, literally conjured up right on cue):

S94 ~ Turn on phase inversion for one channel (Volume = Volume - 1 EOR FF)
S95 ~ Turn off phase inversion for one channel
S96 ~ Turn on phase inversion for all channels
S97 ~ Turn off phase inversion for all channels
S98 ~ Set Zxx Mode to Direct Gain
S99 ~ Set Zxx Mode to FIR Filter Coefficients
S9A ~ Set Zxx Mode to Master Volume
S9B ~ Set Zxx Mode to Echo Volume (this one's new... and it's supposed to be a substitute for overwriting an Impulse Tracker effect)
S9C ~ Set Zxx Mode to Echo Feedback (this one's new... and it's supposed to be a substitute for overwriting an Impulse Tracker effect)
S9D ~ Set Zxx Mode to Echo Delay/Special (this one's new... and it's supposed to be a substitute for overwriting an Impulse Tracker effect)
S9E~ Set pitch modulation control to Modify Direct Gain (Direct Gain = Originally Intended Volume, and Volume = 7Fh)
S9F~ Set pitch modulation control to Do Not Modify Direct Gain (Direct Gain = 7Fh)

Zxx ~ Set Parameter
If Zxx Mode is set to Direct Gain, then the corresponding channel's direct gain will be modified as such. This can become a Custom Gain if the value is above 7F. Unfortunately gain is not tempo-sensitive... and it doesn't care about volume.
If Zxx Mode is FIR Filter Coefficients than the corresponding channel will modify the corresponding coefficient (either that, or an alternative implementation is that you could link to an array that contains a list of FIR coefficent parameters, provided by the song message... but please don't go out of bounds if this implementation is selected).
If Zxx Mode is Echo Volume, then odd channels modify left echo volume, and even channels modify right echo volume.
If Zxx Mode is Echo Delay/Special, then...
- 00h restores all parameters to original settings
- 01h-0Fh sets the delay (but only up to the original value specified in the module... if you want to go further, then set your default rate higher.)
- 10h resets the FIR coefficients to the module's default settings
- 11h resets the echo volume to the module's default settings
- 12h resets the echo feedback to the module's default settings
- 13h disables echo writes. This essentially means your echo buffer plays nothing but looped audio.
- 14h re-enables echo writes.
- I haven't decided on 15-FF yet.

Warning: You must set the Zxx mode first, or else you'll get an undefined effect.
Warning 2: Echo delay has a semi-delayed effect on the song due to the way the hardware processes the echo.
User avatar
Augustus Blackheart
Posts: 61
Joined: Sat Jul 26, 2014 9:50 am

Re: Sound driver fun

Post by Augustus Blackheart »

That's a great point about IT tracker effects, I never had to think about that before because I use an XM tracker. That should definately be changed.
User avatar
Augustus Blackheart
Posts: 61
Joined: Sat Jul 26, 2014 9:50 am

Re: Sound driver fun

Post by Augustus Blackheart »

I've got the sample directory starting at 0100h and the program at 0300h for the extended pitchmod spc program. I've changed it2spc.cpp and include/snesmod.asm to reflect this change*. Everything works fine in ROM and as an SPC file. Is there any reason why 0100h-01ffh shouldn't be used?

One of the things that I've never gotten around to, but have been meaning to work on, is adding a command line option to SMCONV to select between the various spc programs. So, that's something I'll add soon.

*The original SNESMOD and Pitchmod spc programs are still using the orginal addresses.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Sound driver fun

Post by tepples »

Augustus Blackheart wrote:I've got the sample directory starting at 0100h [...] Is there any reason why 0100h-01ffh shouldn't be used?
Stack pointer starts at $01EF and grows down. Too many nested subroutine calls will blow up your sample directory.
User avatar
Augustus Blackheart
Posts: 61
Joined: Sat Jul 26, 2014 9:50 am

Re: Sound driver fun

Post by Augustus Blackheart »

tepples wrote:Stack pointer starts at $01EF and grows down. Too many nested subroutine calls will blow up your sample directory.
D'oh! I probably should have read a doument on the SPC or something. I figured that it was programmed that way for a reason. Everything has been put back in it's proper place.

KungFuFurby, what about using S0D, S0E, S0F to reset delay, echo and feedback to the default settings. S00 could possibly reset delay, echo and feedback, or reset the FIR coefficients.

It's up to 5679 bytes right now but I haven't implemented the following yet: phase inversion, direct gain Zxx mode, FIR coefficients Zxx mode, pitch modulation control to modify/not modify direct gain, disable echo writes, and enable echo writes. Zxx mode echo volume sets the actual echo level right now and doesn't have odd channels modify left echo volume, and even channels modify right echo volume.
KungFuFurby
Posts: 275
Joined: Wed Jul 09, 2008 8:46 pm

Re: Sound driver fun

Post by KungFuFurby »

S0D ~ reset echo delay (alternately, this could be disable echo writes)
S0E ~ reset echo volume (alternately, this could be enable echo writes)
S0F ~ reset echo feedback
I'll accept these changes and move Z13-Z14 to Z11-Z12 since now there's nothing there.

May as well call this big featureset "Super SNESMod" for what it's doing right now.

As of your current version (0.4)...

- Master volume can go past 7Fh... but they'll all be negative values. You can omit the check to save some bytes... just make sure to indicate that you'll get negative volume values if you go past that value.

- I actually wanted to have echo volume be applied without scaling via the master volume (Zxx can help with that by enabling and disabling the scaling). I have a special effect that I could use that involves fooling around with FIR coefficients, setting the EDL as low as possible for smooth transitions, zeroing out the feedback and master volume (without zeroing out the echo volume)... and you'll get filtering on the entire sound output.

- MODULE can be a dynamically changing variable that can also be not divisible by $100. Simply pre-compile the SPC700 source code (with MODULE being essentially a pointer to the end of the current source code... I think that converts OK for TASM), and have SMCONV make its pointers based off of which version you choose.

The following are bugs/concerns from the original SNESMod:

- Fast linear increase is never executed due to multiplication limitations. Volume only ever gets to 7E rather than 7F. This is because of a series of three multiplication operations, none of them skipped, that turns FF into FD, which in turn results in the rather unusual maximum.

- Envelope processing is improperly handled with note delays: they are not delayed with the note, and the previous envelope appears to get frozen in their tracks.

- Envelopes are reset with note slides regardless of whether they finished or not. That's not natural tracker behavior if I remember correctly... I did take advantage of this bug once, though, but I prefer mine not reset.

- The tempo change command can accidentally cause the first tick to come around much later than expected. Most commonly, this is because it's not in the first channel, at least when I noticed it.

- Why is tempo limited to 200? I understand why a lower limit of 80 is mandatory, but tempo can go all the way up to 255, and the timer is able to go that fast.

- Tempo ticks need to be recalibrated. SNESMod's timing, compared to Schism Tracker, is off by (current tempo - 3). This is best indicated when using samples that are timing sensitive to go smoothly, drumbeat samples in particular.

- Ultra low pitches produce glitched values instead of actual low value. Yes, I was crazy enough to go that low with the pitch.

The following are bugs of my original modifications:

- Noise and pitch modulation are not safe with SFX. Echo is in the same boat, but it is not as serious.

Your current version concerns me in the following fashion:

- The way your Zxx code is executed looks quite fatal to SNESMod's standard. That's because the X register is reserved for the channel ID. I would recommend saving the accumulator in m0 (which is fully open in this case), get the parameter mode, then

Also, where did your smconv and snesmod_dev.asm files go? They were here previously...
User avatar
Augustus Blackheart
Posts: 61
Joined: Sat Jul 26, 2014 9:50 am

Re: Sound driver fun

Post by Augustus Blackheart »

KungFuFurby wrote:As of your current version (0.4)...

- Master volume can go past 7Fh... but they'll all be negative values. You can omit the check to save some bytes... just make sure to indicate that you'll get negative volume values if you go past that value.

...

Your current version concerns me in the following fashion:

- The way your Zxx code is executed looks quite fatal to SNESMod's standard. That's because the X register is reserved for the channel ID. I would recommend saving the accumulator in m0 (which is fully open in this case), get the parameter mode, then
Thanks, I didn't get all the changes from my other version into this one. I've updated it now.
Also, where did your smconv and snesmod_dev.asm files go? They were here previously...
I'll add new versions to the first post as soon as I test the latest code. I've only tested the version which uses unimplemented impulse tracker commands for setting all of these features.
User avatar
Augustus Blackheart
Posts: 61
Joined: Sat Jul 26, 2014 9:50 am

Re: Sound driver fun

Post by Augustus Blackheart »

I've added a version with all sfx streaming code removed.

Also, what would be a good option for commands to handle filter sweeps?

I could use z01-05 (which would require an additional S9x command to enable this mode) for different types of filter sweeps and values higher than that could set the delay between each change. I would also need a way to avoid overflows. I've done this so far by hardcoding the values and adding addtional delays for some of the coefficients.

I'm starting to run out of commands to use. What about repurposing the Tremor command. Does anybody actually use that?

Anyway, for anybody who is interested I made my tracker have an SNESMOD option so if I'm tracking for the SNES it shows me what the commands do and when enabled the tracker ignores SNESMOD specific commands on playback. This lets me use way more commands (at the expense of compatibility should I want to use the mod for some other purpose; then again there are already issues when pitch modultion is used).

I suppose at this point I should add spc700 emulation to the tracker.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Sound driver fun

Post by tepples »

I think I've used the tremor command once or twice years ago, but I forget in which song. Or maybe it was retrigger.
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: Sound driver fun

Post by psycopathicteen »

Looked at the asm file and I can't read it because there's no spaces. Everything is on big wall of text.
DoNotWant
Posts: 83
Joined: Sun Sep 30, 2012 3:44 am

Re: Sound driver fun

Post by DoNotWant »

psycopathicteen wrote:Looked at the asm file and I can't read it because there's no spaces. Everything is on big wall of text.
LF newlines. Don't open it in notepad, it won't work, it will only interpret CR-LF as a new line.
User avatar
Augustus Blackheart
Posts: 61
Joined: Sat Jul 26, 2014 9:50 am

Re: Sound driver fun

Post by Augustus Blackheart »

DoNotWant wrote:
psycopathicteen wrote:Looked at the asm file and I can't read it because there's no spaces. Everything is on big wall of text.
LF newlines. Don't open it in notepad, it won't work, it will only interpret CR-LF as a new line.

It is ridiculous that it is 2015 and notepad still doesn't know what to do with LF newlines, something so completely trivial to implement. I suppose Microsoft is too busy removing or hiding features people have used for years or forcing them to download adware begging them to update to Windows 10 and/or forcing them to download Windows 10 rather than doing anything useful or worthwhile.

I think many people replace notepad with notepad++, notepad2, or textpad.
KungFuFurby
Posts: 275
Joined: Wed Jul 09, 2008 8:46 pm

Re: Sound driver fun

Post by KungFuFurby »

Some of my older psuedo-SNES songs actually use Ixy (normally I improvise with volume envelopes, but it would be neat to see that actually get implemented).
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Sound driver fun

Post by tepples »

For use as a programmers' text editor, Microsoft did update Notepad. It's called Visual Studio Code.

I'd like to see a tutorial on how to best set up Notepad++ or your other favorite Windows text editor.
Post Reply