1
+ package pl.lemanski.pandamidi.soundFont
2
+
3
+ interface SoundFont {
4
+ /* *
5
+ * Copy a tsf instance from an existing one, use tsf_close to close it as well.
6
+ * All copied tsf instances and their original instance are linked, and share the underlying soundfont.
7
+ * This allows loading a soundfont only once, but using it for multiple independent playbacks.
8
+ * (This function isn't thread-safe without locking.)
9
+ */
10
+ fun copy (): SoundFont
11
+
12
+ /* *
13
+ * Free the memory related to this tsf instance
14
+ */
15
+ fun close ()
16
+
17
+ /* *
18
+ * Stop all playing notes immediately and reset all channel parameters
19
+ */
20
+ fun reset ()
21
+
22
+ /* *
23
+ * Returns the preset index from a bank and preset number, or -1 if it does not exist in the loaded SoundFont
24
+ */
25
+ fun getPresetIndex (bank : Int , presetNumber : Int ): Int
26
+
27
+ /* *
28
+ * Returns the number of presets in the loaded SoundFont
29
+ */
30
+ fun getPresetsCount (): Int
31
+
32
+ /* *
33
+ * Returns the name of a preset index >= 0 and < tsf_get_presetcount()
34
+ */
35
+ fun getPresetName (presetIndex : Int ): String
36
+
37
+ /* *
38
+ * Returns the name of a preset by bank and preset number
39
+ */
40
+ fun bankGetPresetName (bank : Int , presetNumber : Int ): String
41
+
42
+ /* *
43
+ * Setup the parameters for the voice render methods
44
+ * @param outputMode: if mono or stereo and how stereo channel data is ordered
45
+ * @param sampleRate: the number of samples per second (output frequency)
46
+ * @param globalGainDb: volume gain in decibels (>0 means higher, <0 means lower)
47
+ */
48
+ fun setOutput (outputMode : OutputMode , sampleRate : Int , globalGainDb : Float )
49
+
50
+ /* *
51
+ * Set the global gain as a volume factor
52
+ * @param globalGain: the desired volume where 1.0 is 100%
53
+ */
54
+ fun setVolume (globalGain : Float )
55
+
56
+ /* *
57
+ * Set the maximum number of voices to play simultaneously
58
+ * Depending on the soundfont, one note can cause many new voices to be started,
59
+ * so don't keep this number too low or otherwise sounds may not play.
60
+ *
61
+ * @param maxVoices: maximum number to pre-allocate and set the limit to
62
+ * @throws IllegalArgumentException if allocation failed
63
+ */
64
+ fun setMaxVoices (maxVoices : Int )
65
+
66
+ /* *
67
+ * Start playing a note
68
+ * @param presetIndex preset index >= 0 and < getPresetCount()
69
+ * @param key note value between 0 and 127 (60 being middle C)
70
+ * @param velocity velocity as a float between 0.0 (equal to note off) and 1.0 (full)
71
+ * @throws IllegalArgumentException if allocation of a new voice failed
72
+ */
73
+ fun noteOn (presetIndex : Int , key : Int , velocity : Float )
74
+
75
+ /* *
76
+ * Start playing a note
77
+ * @param bank instrument bank number (alternative to presetIndex)
78
+ * @param presetNumber preset number (alternative to presetIndex)
79
+ * @param key note value between 0 and 127 (60 being middle C)
80
+ * @param velocity velocity as a float between 0.0 (equal to note off) and 1.0 (full)
81
+ * @throws IllegalArgumentException if preset does not exist or allocation failed
82
+ */
83
+ fun bankNoteOn (bank : Int , presetNumber : Int , key : Int , velocity : Float )
84
+
85
+ /* *
86
+ * Stop playing a note
87
+ * @param presetIndex preset index >= 0 and < getPresetCount()
88
+ * @param key note value between 0 and 127 (60 being middle C)
89
+ */
90
+ fun noteOff (presetIndex : Int , key : Int )
91
+
92
+ /* *
93
+ * Stop playing a note
94
+ * @param bank instrument bank number (alternative to presetIndex)
95
+ * @param presetNumber preset number (alternative to presetIndex)
96
+ * @param key note value between 0 and 127 (60 being middle C)
97
+ * @throws IllegalArgumentException if preset does not exist
98
+ */
99
+ fun bankNoteOff (bank : Int , presetNumber : Int , key : Int )
100
+
101
+ /* *
102
+ * Stop playing all notes (end with sustain and release)
103
+ */
104
+ fun noteOffAll ()
105
+
106
+ /* *
107
+ * @return the number of active voices
108
+ */
109
+ fun activeVoiceCount (): Int
110
+
111
+ /* *
112
+ * Supported output modes by the render methods
113
+ */
114
+ enum class OutputMode {
115
+ /* *
116
+ * Two channels with single left/right samples one after another
117
+ */
118
+ TSF_STEREO_INTERLEAVED ,
119
+
120
+ /* *
121
+ * Two channels with all samples for the left channel first then right
122
+ */
123
+ TSF_STEREO_UNWEAVED ,
124
+
125
+ /* *
126
+ * A single channel (stereo instruments are mixed into center)
127
+ */
128
+ TSF_MONO
129
+ }
130
+ }
0 commit comments