API Reference
fluidpatcher.FluidPatcher
An interface for running FluidSynth using patches
Provides methods for:
- loading/saving the config file and bank files
- applying/creating/copying/deleting patches
- directly controlling the Synth by modifying fluidsettings, manually adding router rules, and sending MIDI events
- loading a single soundfont and browsing its presets
Attributes: |
|
---|
See the documentation for information on bank file format.
Source code in fluidpatcher/__init__.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
currentbank
property
a Path object pointing to the current bank file
bankdir
property
Path to bank files
sfdir
property
Path to soundfonts
mfilesdir
property
Path to MIDI files
plugindir
property
Path to LADSPA effects
patches
property
List of patch names in the current bank
__init__(cfgfile, **fluidsettings)
Creates FluidPatcher and starts FluidSynth
Starts fluidsynth using settings found in yaml-formatted cfgfile
.
Settings passed via fluidsettings
will override those in config file.
See https://www.fluidsynth.org/api/fluidsettings.xml for a
full list and explanation of settings. See documentation
for config file format.
Parameters: |
|
---|
Source code in fluidpatcher/__init__.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
update_config()
Write current configuration stored in cfg
to file.
Source code in fluidpatcher/__init__.py
108 109 110 111 |
|
load_bank(bankfile='', raw='')
Load a bank from a file or from raw yaml text
Parses a yaml stream from a string or file and stores as a
nested collection of dict and list objects. The top-level
dict must have at minimum a patches
element or an error
is raised. If loaded from a file successfully, that file
is set as currentbank
in the config - call update_config()
to make it persistent.
Upon loading, resets the synth, loads all necessary soundfonts,
and applies settings in the init
element. Returns the yaml stream
as a string. If called with no arguments, resets the synth and
restores the current bank from memory.
Parameters: |
|
---|
Returns: yaml stream that was loaded
Source code in fluidpatcher/__init__.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
save_bank(bankfile, raw='')
Save a bank file
Saves the current bank in memory to bankfile
after rendering it as
a yaml stream. If raw
is provided, it is parsed as the new bank and
its exact contents are written to the file.
Parameters: |
|
---|
Source code in fluidpatcher/__init__.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
apply_patch(patch)
Select a patch and apply its settings
Read the settings for the patch specified by index or name and combine them with bank-level settings. Select presets on specified channels and unsets others, clears router rules and applies new ones, activates players and effects and deactivates unused ones, send messages, and applies fluidsettings. Patch settings are applied after bank settings. If the specified patch isn't found, only bank settings are applied.
Parameters: |
|
---|
Returns: a list of warnings, if any
Source code in fluidpatcher/__init__.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
add_patch(name, addlike=None)
Add a new patch
Create a new empty patch, or one that copies all settings other than instruments from an existing patch
Parameters: |
|
---|
Returns: the index of the new patch
Source code in fluidpatcher/__init__.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
update_patch(patch)
Update the current patch
Instruments and controller values can be changed by program change (PC) and continuous controller (CC) messages, but these will not persist in the patch unless this function is called. Settings can be saved to a new patch by first calling add_patch(), then update_patch() on the new patch. The bank file must be saved for updated patches to become permanent.
Parameters: |
|
---|
Source code in fluidpatcher/__init__.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
delete_patch(patch)
Delete a patch from the bank in memory
Bank file must be saved for deletion to be permanent
Parameters: |
|
---|
Source code in fluidpatcher/__init__.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
fluidsetting_get(opt)
Get the current value of a FluidSynth setting
Parameters: |
|
---|
Returns: the setting's current value as float, int, or str
Source code in fluidpatcher/__init__.py
307 308 309 310 311 312 313 314 315 |
|
fluidsetting_set(opt, val, patch=None)
Change a FluidSynth setting
Modifies a FluidSynth setting. Settings without a "synth." prefix
are ignored. If patch
is provided, these settings are also added to
the current bank in memory at bank level, and any conflicting
settings are removed from the specified patch - which should ideally
be the current patch so that the changes can be heard. The bank file
must be saved for the changes to become permanent.
Parameters: |
|
---|
Source code in fluidpatcher/__init__.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
add_router_rule(**pars)
Add a router rule to the Synth
Directly add a router rule to the Synth. This rule will be added after the current bank- and patch-level rules. The rule is not saved to the bank, and will disappear if a patch is applied or the synth is reset.
Returns: |
|
---|
Source code in fluidpatcher/__init__.py
342 343 344 345 346 347 348 349 350 351 352 353 |
|
send_event(msg=None, type='note', chan=1, par1=0, par2=0)
Send a MIDI event to the Synth
Sends a MidiMessage, or constructs one from a bank file-styled string
(
Parameters: |
|
---|
Source code in fluidpatcher/__init__.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
|
solo_soundfont(soundfont)
Suspend the current bank and load a single soundfont
Resets the Synth, loads a single soundfont, and creates router rules that route messages from all channels to channel 1. Scans through each bank and program in order and retrieves the preset name. After this, select_sfpreset() can be used to play any instrument in the soundfont. Call load_bank() with no arguments to restore the current bank.
Parameters: |
|
---|
Returns: a list of (bank, prog, name) tuples for each preset
Source code in fluidpatcher/__init__.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
select_sfpreset(sfont, bank, prog, *_)
Select a preset on channel 1
Call to select one of the presets in the soundfont loaded by solo_soundfount(). The variable-length garbage argument allows this function to be called by unpacking one of the tuples returned by solo_soundfont().
Parameters: |
|
---|
Returns: a list of warnings, empty if none
Source code in fluidpatcher/__init__.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
|
The full API reference can be found in the official documentation