项目作者: jarmitage

项目描述 :
Resonant filter bank synthesis on Bela based on [resonators~] Max/Pd object
高级语言: C++
项目地址: git://github.com/jarmitage/resonators.git
创建时间: 2019-03-29T15:54:32Z
项目社区:https://github.com/jarmitage/resonators

开源协议:

下载


Resonators

Resonant filter bank synthesis on Bela based on the [resonators~] Max/Pd object:

  1. #include <Bela.h>
  2. #include "Resonators.h"
  3. #include "Model.h"
  4. ResonatorBank resBank;
  5. ResonatorBankOptions resBankOptions = {};
  6. ModelLoader model;
  7. bool setup(BelaContext *context, void *userData) {
  8. model.load("models/marimba.json");
  9. resBankOptions.total = model.getSize();
  10. resBank.setup(resBankOptions, context->audioSampleRate, context->audioFrames);
  11. resBank.setBank(model.get());
  12. resBank.update();
  13. return true;
  14. }
  15. void render(BelaContext *context, void *userData) {
  16. for (unsigned int n = 0; n < context->audioFrames; ++n) {
  17. float in = audioRead(context, n, 0); // an excitation signal
  18. float out = resBank.render(in);
  19. audioWrite(context, n, 0, out);
  20. audioWrite(context, n, 1, out);
  21. }
  22. }

The corresponding marimba.json:

  1. {
  2. "metadata": {
  3. "name": "marimba",
  4. "fundamental": 800,
  5. "resonators": 8
  6. },
  7. "resonators": [
  8. { "freq": 800, "gain": 0.500000, "decay": 0.2 },
  9. { "freq": 1600, "gain": 0.033333, "decay": 0.4 },
  10. { "freq": 2400, "gain": 0.016666, "decay": 0.6 },
  11. { "freq": 3200, "gain": 0.006666, "decay": 0.7 },
  12. { "freq": 4000, "gain": 0.003333, "decay": 0.8 },
  13. { "freq": 4800, "gain": 0.001666, "decay": 0.9 },
  14. { "freq": 5400, "gain": 0.000666, "decay": 1.0 },
  15. { "freq": 6200, "gain": 0.000333, "decay": 1.0 }
  16. ]
  17. }

Bela examples

  1. An individual resonator.
  2. A bank of resonators based on a model file.
  3. Loading updated models periodically into a bank of resonators via scp.
  4. Multiple banks of resonators based on a model file, tranposed up a scale.
  5. Combination of examples 3 & 4, plus Bela scope for inputs.

Resonance models

Collection of ~100 resonance models of mostly percussion instruments, based on aLib resonance models

  • Indian percussion instruments (Chakoa, Dhalki, Hand-Dhal, khol, Madal, Manjeera, Mirdangam, Stick-Dhal)
  • A set of 12 Ghanaian double-bells, recorded with hard and soft beater
  • Guitar strings plucked behind the bridge
  • SampleCell Dumbeck, Gong

p5.js GUI

WIP! Relies on Bela WebSocket server wrapper and integration with Resonator.h.

  • BelaWS.js: connects to Bela over a Web Socket
  • Resonators.js: real-time bidirectional updating of resonator model, using p5.js

p5_gui


Jupyter & Python

Some convenience functions, not pretty yet…

  • Importing Max/Pd formatted models (see references below)
  • Working with models as Pandas dataframes
  • Loading/saving/converting to/from .csv .coll & .json
  • scp-ing models to Bela for real-time updates

jupyter_plot


Max/Pd References


Python Bindings

Bindings for Python are available via Swig, meaning Resonators can be used from a Python script or a Jupyter notebook:

  1. model = resonators.ModelLoader()
  2. model.load(args.model_path)
  3. rb_ops = resonators.ResonatorBankOptions()
  4. rb_ops.total = model.getSize()
  5. rb = resonators.ResonatorBank()
  6. rb.setup(rb_ops, 44100.0, 128)
  7. rb.setBank(model.getShiftedToNote("c4"))
  8. rb.update()
  9. out = rb.render(0.5)
  • At the top level directory, run cmake ., and then make.
  • If this succeeds, run py/test_bindings.py to confirm.
  • For now, you can crudely sys.path.append the directory to import the module.

Note: this has been tested with Python 3.6.5 (and should support Python 2.7+), SWIG 4.0.0 and CMake 3.14.3 on OSX 10.14.


License

Unless otherwise stated, CC0.


TODO

Resonators
  • More comprehensive comments/documentation
  • Add examples for real-time manipulation of model parameters
  • Add functions for useful/interesting real-time variation of model parameters
Models
  • Real-time functions for simple scaling of gain and decay parameters
  • Generate models (offline) based on samples (using HPSS?)
Data analysis/offline exploration

[x] Python bindings for Resonators.cpp for offline synthesis (merged 05c089c)

  • Clean up Python utils
  • Add Jupyter notebook examples
p5.js