SFe-Team-was-taken / SFe

Bringing soundfonts to new heights
1 stars 1 forks source link

SFt Proposal #1: Initial Idea #6

Open spessasus opened 1 month ago

spessasus commented 1 month ago

Since SFe isn't really backwards compatible (see RIFF64, TSC or changing words to dwords, I propose to revise the file structure to remove all limits. It is heavily inspired by the DLS file structure.

My proposal

TOC

This proposal is intended to create a proper SoundFont v3 file format that can be (hopefully) infinitely expanded.

ALL UNKNOWN CHUNKS HAVE TO BE IGNORED AND PRESERVED AS READ

file extension

.sft - short for "SoundFonT"

Definitions

The INFO chunk

There's a defined INFO chunk that can be added to almost everything. It is described below.

All chunks here are 32 bits (no need for more than 4GB of text, come on)

All text chunks must use the utf-8 encoding!

All chunks within the INFO chunk are strings unless explicitly stated otherwise.

This chunk is denoted as INFOLIST in the format below, optionally listing additional chunks for this specific field.

Curve

SFZ defines the concept of curves. Let's add them here!

The Curve is defined as an X number of points. The First one has to be 0, the last one has to be 1. The points are evenly spaced apart and interpolated LINEARLY.

Curve chunk

Here's a curve chunk

for example, for a basic linear curve, you would do

Modulator Index list

A simple list describing the used modulators. Used in presets, instruments, and the default mod list.

Sample

Here's a chunk that describes a single sample.

Audio types

The TYPE chunk within a sample chunk describes the type of bitstream the sample uses.

Currently, I can think of these types:

More can be added later (up to 32k!)

Up to two channels of audio are allowed. They shall be interpreted as effectively two samples with exactly the same generators, except for pan which is forced to -1 on the left sample and 1 on the right.

Generator list

Here's a generator list.

Another thing, since the value is a float now, I propose changing timecents to seconds (or miliseconds?). It would make things A LOT easier. Also making pan be -1 to 1.

Modulator

The modulator is something I'm unsure about, but it has to implement the following:

Instrument

Here's a chunk that describes a single instrument

Preset

Here's a chunk that describes a single preset

File format

Sample data

THe SD64 contains all the sample data. All the data is a bunch of bitstreams one after another.

For example, if the first sample was WAVE and a second one was FLAC, the bitstream would start with the WAVE file and just after that there would be the FLAC file pasted in.

Conclusion

What do you think of this format? Is it any good?? Let me know!

stgiga commented 1 month ago

You have some great ideas.

spessasus commented 1 month ago

Thanks, @stgiga ! There are a few things I thought of but missed when writing above though:

modulators

  1. Source can be one of 4 types:
    • MIDI CC num (like in SF2)
    • special controller: like key num, velocity, channel pressure, poly pressure
    • RPN value: like pitch bend range, coarse and fine tuning, modulation depth. These 4 would also have the stock modulators built in
    • NRPN value: a 14-bit value of both LSB and MSB: it can allow us to program in stuff like GS vibrato!!!

Maybe even somehow program in sysEx messages? (like if manufacturer ID is this and nth byte is this and that, then take byte X as the value). It is probably a bit too complex though (or is it? ;-)

  1. more transforms:

    • source has its own transform
    • control (secondary source) has its own transform
    • output has its own transform
    • absolute value
    • absolute value * -1
    • floor
    • ceiling
    • modulo by something
    • clip output to given range (for example a bipolar linear curve which only allows values from 0 up, effectively disabling the modulator if source is below half)
  2. changing type

    • add (default)
    • subtract
    • multiply
    • divide
    • override (only one modulator can be used on this generator if it overrides to prevent race conditions)

samples

  1. Sample interpolation types. I can think of 4 now:

    • linear
    • nearest neighbor: this would make things like square wave only require one sample without it losing its "sharpness" when played at low tones
    • 4th order
    • 7th order (would be default)
  2. Loop types, it would be a flag that goes after loopCount:

    • forwards (normal)
    • back and forth (one direction change is considered one loop)
    • backwards

Generators

custom chorus

stgiga commented 1 month ago

Funnily enough, having those extra fields can improve Roland SC-88Pro and SC-8850/8820/SC-D70 Insertion EFX (CC94), as well as open up whatever fancy stuff MU2000EX XG3 does. So I'm OK with implementing this, and I've gotten the other team member involved.

spessasus commented 1 month ago

Funnily enough, having those extra fields can improve Roland SC-88Pro and SC-8850/8820/SC-D70 Insertion EFX (CC94), as well as open up whatever fancy stuff MU2000EX XG3 does. So I'm OK with implementing this, and I've gotten the other team member involved.

Well, that's what I was thinking of, specifically the 88Pro. I actually started my MIDI and soundfont adventure by discovering MIDIs made for 88Pro. So recreating these perfectly would be amazing!

stgiga commented 1 month ago

My first major SoundFont was an 88Pro SoundFont, and these days Tyroland (and some others, but on back burner because college) has good SC-8850 support created from the Tyros4+JV1010 samples in a long process.

The project lead got into SC-88x support because of my efforts (which have roots as far back as 2015), because I hated seeing broken songs. So I think even the project lead would be interested.

sylvia-leaf commented 1 month ago

@spessasus Thank you for the draft for the SFe rework. Sorry for taking so long to write my response.

Naturally, because you came up with a complete re-structuring of the SFe specification, I've got a lot of feedback to give you.

You do have some good ideas, and I'll be working on version 4.00.6 of the specification, which splits the versions of SFe apart. Please check the branches of the repository for a preview. If you want to be part of the SFe team, then please tell me!

sylvia-leaf commented 1 month ago

Forgot to add this. The many features that you mention that are incompatible with SF2.04 such as TSC, DWORDs and RIFF64, are mostly absent in the SFe32 specification.

Please take a look at the SFe32-only branch of the repository for the compatible version of the SFe specification.

Also, if you have any suggestions about where we can place the TSC implementation info so we can make it clear that using TSC will make your file incompatible with some players? Or should we scrap TSC all together?

We'll probably remove TSC implementation info temporarily for 4.00.6. We'll also plan to bring it back at a future date, maybe as part of SFe64L.

stgiga commented 1 month ago

I DO NOT want TSC scrapped.

spessasus commented 1 month ago

What's the point of TSC?

Just use 64-bit riff chunks like I suggested and then you have practically no size constraints.

Since TSC is already fundamentally incompatible with sf2, why not just skip to 64?

stgiga commented 1 month ago

What's the point of TSC?

Just use 64-bit riff chunks like I suggested and then you have practically no size constraints.

Since TSC is already fundamentally incompatible with sf2, why not just skip to 64?

I mean, it was to make 32bit at least not be a complete rewrite for more samples.

sylvia-leaf commented 1 month ago

Alright, there seems to be some disagreement about the TSC mode. Let me try to understand what's going on:

Right now, I'm going to propose this compromise:

Stuff to do:

spessasus commented 1 month ago

Alright, let's sum my thoughts up:

TSC is putting SDTA at the end of the file. This is fundamentally incompatible with SF2 and therefore with all Sound Blasters and softsynths. So, a rewrite. Not to mention that there's no point in TSC with SB as they can load up to 30MB (or something like that) soundfonts. So the only advantage it brings (larger SDTA limit) is nullified.

RIFF64 is making some chunks use 64-bit length rather than 32-bit and changing the 2 last letters of fourCC to 64 (in ASCII). This is also fundamentally incompatible, so a rewrite.

Now, here's what a "rewrite" means for SpessaSynth for both of these:

As you can see, TSC is very much a major rewrite, unlike the 64-bit extension (at least in SpessaSynth's case). And not to mention, come on. All modern computers are 64-bit. The only major exception would be the hardware soundblasters which don't take advantage of TSC anyways.

And even then, the 64-bit mode could work for 32 bit machines. The spec could add the following:

For 32-bit software, 64-bit chunks have to be checked. Any of the top four bytes is not set to 0, this means that the chunk size is above 32-bit maximum and the file should be rejected as incompatible with the architecture. If the top four bytes are all set to zero, the chunk must be read and played normally.

sylvia-leaf commented 1 month ago

So, you've shown that it is a lot easier for a software developer to adapt to 64-bit than to use TSC mode.

Therefore, we're going to be moving TSC mode to its own specification separate from SFe. It will require the player to support SFe, but SFe won't require it. Version 1.0 of this specification should be released alongside of SFe 4.00 or 4.01.

To facilitate this method of developing features, we are working on giving the ISFe chunk its first use, as a "feature flag" system. The specific flag used for TSC will be well-defined, but the information on TSC will be absent from SFe specifications until we've sorted out where TSC mode should go.

sylvia-leaf commented 3 weeks ago

So, you've shown that it is a lot easier for a software developer to adapt to 64-bit than to use TSC mode.

Therefore, we're going to be moving TSC mode to its own specification separate from SFe. It will require the player to support SFe, but SFe won't require it. Version 1.0 of this specification should be released alongside of SFe 4.00 or 4.01.

To facilitate this method of developing features, we are working on giving the ISFe chunk its first use, as a "feature flag" system. The specific flag used for TSC will be well-defined, but the information on TSC will be absent from SFe specifications until we've sorted out where TSC mode should go.

sylvia-leaf commented 3 weeks ago

For now, TSC mode has been moved to a separate specification independent of SFe. However, this may change in the future. Sorry for posting the same reply twice!