GithubHelp home page GithubHelp logo

bradhowes / sf2libau Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 7.45 MB

AUv3 MIDI instrument with sound font (SF2) rendering

License: MIT License

Swift 100.00%
audio-processing auv3 coreaudio ios macos sf2 soundfont

sf2libau's Introduction

SF2LibAU - AUv3 MIDI instrument with sound font (SF2) rendering [BETA]

The code defines an AUAudioUnit MIDI component in Swift that uses the SF2Lib engine for rendering audio samples.

Currently, the AUv3 component:

  • responds to MIDI messages and can render audio
  • supports loading of SF2 files via custom sysex MIDI command
  • supports selecting of a preset by bank/program as well as index position

The unit tests contain examples showing all of the above.

NOTE: requires Swift 5.9 for it's Swift/C++ interoperability facility.

Parameter Control

An SF2 file contains a collection of instruments and presets each of which contains a set of values for the SF2 synthesizer parameters (generators) and modulator mappings; those for instruments are absolute values, while the preset values are always relative, adding to an instrument's value. Many of these parameters can be modified in real-time by two means:

  • AUv3 parameter changes communicated via the AUParameterTree instance provided by the AUv3 instrument.

  • MIDI control messages using "NRPN" MIDI control. From the SF2 spec:

NRPN stands for Non Registered Parameter Number. The MIDI specification has defined this series of continuous controllers to permit General MIDI compatible synthesizers to take advantage of their proprietary hardware by using these messages to control the non-General MIDI compatible aspects of their hardware. The SoundFont 2.01 specification uses these messages to allow arbitrary real-time control over all SoundFont synthesis parameters.

Note that some MIDI control messages will by default also effect a parameter change. For instance, MIDI pitch bend messages affect the pitch of the note being played, and MIDI controllers 64 (sustain pedal), 66 (soft pedal), and 67 (sostenuto pedal) affect the envelope behavior of a playing note.

AUParameterTree

The AUParameterTree for the SF2 engine contains entries for all of the implemented generators. See the SF spec for descriptions of these generators and their valid value ranges.

Address Name
0 startAddrsOffset
1 endAddrsOffset
2 startloopAddrsOffset
3 endloopAddrsOffset
4 startAddrsCoarseOffset
5 modLfoToPitch
6 vibLfoToPitch
7 modEnvToPitch
8 initialFilterFc
9 initialFilterQ
10 modLfoToFilterFc
11 modEnvToFilterFc
12 endAddrsCoarseOffset
13 modLfoToVolume
15 chorusEffectsSend
16 reverbEffectsSend
17 pan
21 delayModLFO
22 freqModLFO
23 delayVibLFO
24 freqVibLFO
25 delayModEnv
26 attackModEnv
27 holdModEnv
28 decayModEnv
29 sustainModEnv
30 releaseModEnv
31 keynumToModEnvHold
32 keynumToModEnvDecay
33 delayVolEnv
34 attackVolEnv
35 holdVolEnv
36 decayVolEnv
37 sustainVolEnv
38 releaseVolEnv
39 keynumToVolEnvHold
40 keynumToVolEnvDecay
43 keyRange
44 velRange
45 startloopAddrsCoarseOffset
46 keynum
47 velocity
48 initialAttenuation
50 endloopAddrsCoarseOffset
51 coarseTune
52 fineTune
54 sampleModes
56 scaleTuning
57 exclusiveClass
58 overridingRootKey

NOTE: any address not listed above will not be found in the AUParameterTree due to gaps in the SF spec.

All values for the elements in the AUParameterTree are floating-point values which will be converted into integer values that conform to the spec. For boolean (true/false )settings, values < 0.5 will be treated as false and values >= 0.5 will be true.

There are additional parameters definitions for MIDI control state:

Address Name Description
1000 portamentoModeEnabled Portamento mode (aka glide)
1001 portamentoRate How must time to transition for each step
1002 oneVoicePerKeyModeEnabled When enabled, playing same key will cancel previous voice
1003 polyphonicModeEnabled When enabled, supports playing multiple notes at same time
1004 activeVoiceCount Reports the number of active voices (read-only)
1005 retriggerModeEnabled When enabled, playing same voice restarts the envelope of the voice

sf2libau's People

Contributors

bradhowes avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.