Strategy

Java Language Programming

The Java programming language is appropriate for this project. It is relatively platform and operating system independent, and has built-in facilities for reading, writing, and processing audio files. However, the project was developed on a Windows 98 system and used WAVE (.WAV) format files for audio input and analysis (test output).

Goals

The long-term goal (not yet realized) of this project is a Java program to take an input audio file or set of files and to automatically generate a complementary pair of output files:

Current Accomplishments

The short-term accomplishment of the project is to be able to generate a SoundFont (.SF2) file using a combination of Java programs and utility programs, and to test the SoundFont with manually-created test MIDI (.MID) files.

Initially, I experimented with existing SoundFont files and a SoundFont compiler-decompiler called SF2Comp which I downloaded from the Internet. The output of SF2Comp in decompiler mode is a set of WAVE sample files (extracts of the samples originally embedded in the SoundFont) and a text (.TXT) file with a structured, human-readable listing of the WAVE files and all the non-default parameters in the SoundFont, such as filter parameters, MIDI Patch Number mappings, layering, etc. This same file (or an edited version of it) can be read in along with the WAVE files it specifies (in compiler mode) to create a new SoundFont, so there is a complete round-trip.

After much manual experimentation with these text files, I constructed a simple Java program to generate them from scratch using a smaller number of parameters. At present, the parameters are “hard-coded” into the program, but eventually some will be derived in part by the program directly analyzing the WAVE sample files, and the rest (not derivable) from extremely small text files (or a database) providing user-supplied mappings such as the desired MIDI Patch Numbers. This Java program will also eventually directly create the SoundFont files, eliminating the need for the intermediate text files and thus also the need for the SF2Comp program.

Testing

For testing, a MIDI “rendering” program, Audio Compositor, was used to produce an output WAVE (.WAV) file for analysis in Sound Forge XP Studio. This bypassed potential resampling problems from mixes of 44.1 kHz and 48 kHz sampling in the original samples and the output of my SoundBlaster Live! sound card. Thus all WAVE files, input and output, were in 44.1 kHz.

Mapping Sample Files to MIDI Patch Numbers, Note Numbers, and Velocities

I am more or less following the Early Patches system of assigning MIDI Patch Numbers and MIDI Note Numbers, but I depart radically from their system with my method of assigning MIDI Velocity.

The Early Patches audio sample file names are of the form <Folder>\<Quality>_<Dynamic>.wav, for example Bendir\Slap_fff.wav, where <Quality> indicates the “quality” of the drum hit, e.g. Slap, Bass, Rim.

Quality

NN

Bab

67

Bab1

 

Bass

67

Cent

67

CenterLt

 

CenterRt

 

CenterSnare

 

CenterSt

 

Drop

64

Excenter

69

ExcenterLt

 

ExcenterRt

 

ExcenterSt

 

Medium

69

Mitte

67

Nosnare

69

Rand

60

Rand

69

Rim

69

RimL

69

RimL

71

RimR

60

RimR

69

RimR

71

Roll

62

Slap

65

Slp1

65

Slp2

64

Slpdr

64

Snare

67

Weich

67

Zil1

71

Zil2

72

Zweig1

64

Zweig2

65

 

MIDI Note Number

The table at the left (derived from the summary table of audio sample files) is a complete alphabetical list of the <Quality> part of all the drum audio sample files, paired with the MIDI Note Number (NN) used for the sample in an Early Patches SoundFont file, if any. Basically it assigns a drum “quality” to a “white key” between middle C (MIDI Note Number 60) and C above middle C (MIDI Note Number 72). It has been edited and rationalized somewhat, but I still haven't figured out how to handle the inconsistencies and conflicts of Rand, Rim, RimR and RimL. This table, when finished, will determine the conventional MIDI Note Number to use.

MIDI Velocity

As can be seen from the somewhat sparse summary table of audio sample files, not every dynamic (fff, ff, f, mf, mp, p, pp, ppp) has been sampled for each “quality”; indeed, some have only one dynamic and there are no mp sample files at all. When I examined the Early Patches SoundFont files, I discovered that at most two dynamic files (typically f and p) were actually used for the MIDI dynamic range of 127 down to 1.

However I decided to use as many samples as possible, with MIDI Velocity cross-fades between them. After much experimentation, I settled on the following scheme:

  1. Arbitrarily assign MIDI Velocity 127 to fff, 111 to ff, ... , and 15 to ppp. Call these 8 MIDI Velocities (spaced 16 apart) V-nodes. Call the 7 midpoints between them (119, 103, ... , 23) V-antinodes.
  2. If a file exists with a matching filename <Folder>\<Quality>_<V-node>.wav (for example Bendir\Slap_fff.wav matches V-node fff), then associate this sample with the V-node.
  3. If no such file exists then associate the same sample as the closest V-node with a sample. For example, since there is no Bendir\Bass_ff.wav, V-node ff shares Bendir\Bass_f.wav.
  4. If neighboring V-nodes use the same sample then associate all the intervening MIDI Velocities with that sample also; for example MIDI Velocities 127 down to 95 all use Bendir\Bass_f.wav.
  5. If neighboring V-nodes use different samples, then the intervening MIDI Velocities will be (equal-power) cross-faded by calculating appropriate attenuated portions of both samples, with a -3dB attenuation of both at the midpoint V-antinode.
  6. MIDI Velocities 1-14 use the same sample as 15.

MIDI Patch Number

Each folder (subdirectory) contains all the audio sample files for a single drum (e.g. Bendir\) and has been assigned a unique MIDI Patch Number, which I will adopt unchanged.

Nevertheless, for testing I am using a different temporary strategy:

  • Each SoundFont has only one instrument, e.g. Bendir.sf2. Of course it has each MIDI Note Number associated with an instrument “quality”.
  • MIDI Patch Number 28 is the composite (cross-faded) patch as described in the MIDI Velocity section above.
  • MIDI Patch Number 27 has only the samples assigned to the fff V-node for all Velocities 1-127 (and for each MIDI Note Number).
  • MIDI Patch Number 26 has only the samples assigned to the ff V-node for all Velocities 1-127 (and for each MIDI Note Number).
  • So on down to MIDI Patch Number 21 for the samples assigned to the ppp V-node.
  • By comparing the RMS power of a rendered MIDI Patch Number 27 and MIDI Patch Number 26, both with a MIDI Velocity of 119, i.e. the midpoint between the fff V-node and the ff V-node, the gain of the ff sample can be adjusted to exactly match the fff sample!
  • And so on down the line, each sample gain adjusted to the one “above” it. This 7-step adjustment must be done separately for each MIDI Note Number, i.e. for each instrument “quality”.