Giter Club home page Giter Club logo

maximilian's Introduction

  _____ _____ ___   __ _  _____  __ __   __ ____  ____
 /     \\_   \\  \/  /  |/     \|  |  | |  \_   \/    \
|  Y Y  \/ /_ \>    <|  |  Y Y  \  |  |_|  |/ /_ \  Y  \
|__|_|  (___  /__/\__\__|__|_|  /__|____/__(___  /__|  /
      \/    \/                \/               \/    \/

version GitHub license


What's Maximilian?

Maximilian is a cross-platform and multi-target audio synthesis and signal processing library. It was written in C++ and provides bindings to Javascript. It's compatible with native implementations for MacOS, Windows, Linux and iOS systems, as well as client-side browser-based applications. Maximilian is self-contained, and compiles without dependencies. The main features are:

  • sample playback, recording and looping
  • support for WAV and OGG files.
  • a selection of oscillators and filters
  • enveloping
  • multichannel mixing for 1, 2, 4 and 8 channel setups
  • controller mapping functions
  • effects including delay, distortion, chorus, flanging
  • granular synthesis, including time and pitch stretching
  • atom synthesis
  • real-time music information retrieval functions: spectrum analysis, spectral features, octave analysis, Bark scale analysis, and MFCCs
  • example projects for Windows and MacOS, susing command line and OpenFrameworks environments
  • example projects for Firefox and Chromium-based browsers using the Web Audio API ScriptProcessorNode (deprecated!)
  • example projects for Chromium-based browsers using the Web Audio API AudioWorklet (e.g. Chrome, Brave, Edge, Opera, Vivaldi)
  • will run on embedded systems (e.g. ESP32)

Documentation

in docs/index.html

Basic Examples

Examples demonstrating different features can be found in the maximilian_examples folder. Each example is in a subfolder, and can be built as follows using cmake:

cd [example folder]
mkdir build
cd build
cmake ..
make
./maximilian

Web Audio

A transpiled javascript version of the library is included in this repository, for both Script Processor Nodes and AudioWorklets. Try this out at (https://mimicproject.com/guides/maximJS).

To run this on your on site, locally, or on GitHub Pages, check out this repo.

Mac OS XCode Project

You can run the examples using the 'maximilianTest' XCode 3 project provided.

MS Windows Visual Studio Project

This is in the maximilianTestWindowsVS2010 folder. You will need to install the DirectX SDK, so that the program can use DirectSound.

Command Line Compilation in Mac OS

g++ -Wall -D__MACOSX_CORE__ -o maximilian main.cpp RtAudio.cpp player.cpp maximilian.cpp -framework CoreAudio -framework CoreFoundation -lpthread

For M1 Mac OS

g++ -Wall -D__MACOSX_CORE__ -o maximilian main.cpp RtAudio.cpp player.cpp maximilian.cpp -framework CoreAudio -framework CoreServices -framework AudioToolbox -framework AudioUnit -framework Accelerate -lpthread

./maximilian

Command Line Compilation in Linux

With OSS:

g++ -Wall -D__LINUX_OSS__ -o maximilian main.cpp RtAudio.cpp player.cpp maximilian.cpp -lpthread

With ALSA:

g++ -Wall -D__LINUX_ALSA__ -o maximilian main.cpp RtAudio.cpp player.cpp maximilian.cpp -lasound -lpthread

With Jack:

g++ -Wall -D__UNIX_JACK__ -o maximilian main.cpp RtAudio.cpp player.cpp maximilian.cpp pkg-config --cflags --libs jack -lpthread

then:

./maximilian

OpenFrameworks Project

Maximilian works well with the OpenFrameworks C++ creative coding toolkit (http://www.openframeworks.cc).

In the ofxMaxim directory you will find examples to run in Windows, OSX and iOS, including FFT analysis and granular synthesis.

You can install the ofxMaxim addon by copying the ofxMaxim/ofxMaxim folder into your openframeworks addons directory.

Important: when using Maximilian on OSX, link against the Accelerate framework.

Developer Notes

see developer_notes.md

maximilian's People

Contributors

chriskiefer avatar crushedpixel avatar cthom055 avatar fedden avatar frantic0 avatar jakubfiala avatar junekuhn avatar louismac avatar micknoise avatar mzed avatar nevosegal avatar pavloschatz avatar safareli avatar sieren avatar whg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

maximilian's Issues

Env parameters

The current env params in IR are : trig, A, D, S, R

That's good as we can then store the envelope in a var and use it on many signals (rather than putting the signal as the first argument of the env).

However, the problem is (it seems to me) that the A, D, S, R are defined as milliseconds (or samples). Better have that in seconds, so a typical env would be: 0.1, 0.5, 2, 1

add in FFT example

<title> Javascript Audio Processing </title> <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?autoload=true&skin=sunburst&lang=css" defer="defer"></script> <style type="text/css"> body, button { font-family:Arial, Helvetica, sans-serif; font-size: 16px; } .prettyprint ol.linenums>li { list-style-type: decimal } </style> <script src="maximilian.js"></script> Play <script type="text/javascript"> async function maxi(){ let m = await maximilian(); console.log(m); /** * maxiAudio.init() initialises the Audio Context and should execute in a button click event handler to prevent the console warning * "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu" */ let playAudio = () => { let myOsc = new m.maxiOsc(); let lfo1 = new m.maxiOsc(); let lfo2 = new m.maxiOsc(); let maxiAudio = new m.maxiAudio(); let dist = new m.maxiNonlinearity(); let fft = new m.maxiFFTAdaptor(); let bins = 512; let hopPercentage = 0.25; fft.setup(bins * 2, Math.floor(bins * 2 * hopPercentage), bins * 2); let mags = fft.getMagnitudesAsJSArray(); let phases = fft.getPhasesAsJSArray(); let numCoeffs = 20; let mfcc = new m.maxiMFCCAdaptor(); mfcc.setup(bins, 40, numCoeffs, 20, 20000); let coeffs = new Float64Array(numCoeffs); maxiAudio.init(); maxiAudio.play = function () { let w = myOsc.saw(50); w = dist.asymclip(w*50, lfo1.sinewave(0.1) * 3, lfo2.coswave(0.02) * 3); if (fft.process(w, m.maxiFFTModes.WITH_POLAR_CONVERSION)) { mags = fft.getMagnitudesAsJSArray(); phases = fft.getPhasesAsJSArray(); console.log(mags); coeffs = mfcc.mfcc(mags); console.log(coeffs); } return w; } } const playButton = document.getElementById('playButton'); playButton.addEventListener("click", () => playAudio()); }; maxi(); </script>

Uncaught UnboundTypeError

Hi @chriskiefer

I'm trying to refactor the FFT example (20-analysis-FFT.html) in the SPN version of Maximilian (asm.js).

I'm getting an exception on the maxiFFT.process call. Do you think you could have a look to see if I'm missing something?

Here's the stack trace.

1. UnboundTypeError {name: "UnboundTypeError", message: "Cannot call maxiFFT.process due to unbound types: N7maxiFFT8fftModesE", stack: "UnboundTypeError: Cannot call maxiFFT.process due …ipt-processor-node/build/maximilian.js:119416:22)"}
    1. message: "Cannot call maxiFFT.process due to unbound types: N7maxiFFT8fftModesE"
    2. name: "UnboundTypeError"
    3. stack: "UnboundTypeError: Cannot call maxiFFT.process due to unbound types: N7maxiFFT8fftModesE↵ at UnboundTypeError.<anonymous> (http://localhost:9000/script-processor-node/build/maximilian.js:5077:24)↵ at new UnboundTypeError (eval at createNamedFunction (http://localhost:9000/script-processor-node/build/maximilian.js:1:1), <anonymous>:4:34)↵ at throwUnboundTypeError (http://localhost:9000/script-processor-node/build/maximilian.js:5843:13)↵ at maxiFFT.unboundTypesHandler [as process] (http://localhost:9000/script-processor-node/build/maximilian.js:6213:15)↵ at Module.maxiAudio.maxiAudio.play (http://localhost:9000/script-processor-node/examples/20-analysis-FFT.html:119:13)↵ at Module.maxiAudio.<anonymous> (http://localhost:9000/script-processor-node/build/maximilian.js:119416:22)"
    4. __proto__: Error
        1. constructor: ƒ UnboundTypeError()
        2. toString: ƒ ()
        3. __proto__: Object

throwUnboundTypeError @ maximilian.js:5843

unboundTypesHandler @ maximilian.js:6213

maxiAudio.play @ 20-analysis-FFT.html:119

(anonymous)  @ maximilian.js:119416```

problems loading the new m.wasmmodule.js into the worklet

know for sure it is inclusion of m.wasmmodule.js but can't get any hints about why it is failing (silent error!)

commented out the maxiSample embinding but it didn't work.

do a manual inspection of the m.wasmmodule.js and compare it with the functional ones.

maximilian.post.js needs clean up

  1. need to be careful and check all the versions in different repos
  2. need to check whether to keep support for script processor node and the old Maximilian set up

Add sample playing

  1. add a special 'sample name' string type to the language. This will be a string, starting with "", e.g. \kickdrum.
  2. this will convert automatically to a sample player e.g.
    {{1}sqr}\kickdrum

will convert to (very roughly)

setup:
x= new maxiSample(); loadSample(x, "kickdrum.wav"); y= new maxiOsc();
loop:
if (zeroCrossing(y.square(1)) {x.trigger()};
return x.playOnce();

new Module.maxiOsc() with eval

I get an error when I evaluate a maxiOsc constructor with a sinewave.

() => { return new Module.maxiOsc().sinewave(400)}

Uncaught abort("Cannot enlarge memory arrays to size 16781312 bytes. Either 
(1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 16777216, 
(2) compile with  -s ALLOW_MEMORY_GROWTH=1  which allows increasing the size at runtime but prevents some optimizations, 
(3) set Module.TOTAL_MEMORY to a higher value before the program runs, or 
(4) if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 ") at 
Error
    at jsStackTrace (http://localhost:8000/audioWorklet/maxi-processor-eval-message/maximilian.wasmmodule.js:1080:13)
    at stackTrace (http://localhost:8000/audioWorklet/maxi-processor-eval-message/maximilian.wasmmodule.js:1097:12)
    at abort (http://localhost:8000/audioWorklet/maxi-processor-eval-message/maximilian.wasmmodule.js:90131:44)
    at abortOnCannotGrowMemory (http://localhost:8000/audioWorklet/maxi-processor-eval-message/maximilian.wasmmodule.js:6732:7)
    at _emscripten_resize_heap (http://localhost:8000/audioWorklet/maxi-processor-eval-message/maximilian.wasmmodule.js:6734:7)
    at _sbrk (http://localhost:8000/audioWorklet/maxi-processor-eval-message/maximilian.wasmmodule.js:88767:12)
    at _malloc (http://localhost:8000/audioWorklet/maxi-processor-eval-message/maximilian.wasmmodule.js:42736:15)
    at __Znwm (http://localhost:8000/audioWorklet/maxi-processor-eval-message/maximilian.wasmmodule.js:85087:9)
    at Array.__ZN10emscripten8internal18GenericBindingTypeINSt3__210shared_ptrI7maxiOscEEE10toWireTypeEOS5_ (http://localhost:8000/audioWorklet/maxi-processor-eval-message/maximilian.wasmmodule.js:15443:8)
    at dynCall_ii (http://localhost:8000/audioWorklet/maxi-processor-eval-message/maximilian.wasmmodule.js:88982:38)

(index):75 WASMWorkletProcessor Error detected

building a custom node with options

           let options = {
              numberOfInputs: 0,
              numberOfOutputs: 1,
              outputChannelCount: [2]
            }
            // customNode = new MaxiNode(audioContext, customProcessorName, options);

There is a problem with setting the options and how processing is happening in processor proccess loops.

The symptom is the sample rate of the playback which is low res.

Maximilian: compile errors in maxiConvolve.cpp

I'm getting these errors when EM compiling the WASM. Removed maxiConvolve from the compilation for now

../../../src/libs/maxiConvolve.cpp:20:35: error: no member named 'real' in 'maxiFFT'
            realVector.assign(fft.real, fft.real + fft.bins);
                              ~~~ ^
../../../src/libs/maxiConvolve.cpp:20:45: error: no member named 'real' in 'maxiFFT'
            realVector.assign(fft.real, fft.real + fft.bins);
                                        ~~~ ^
../../../src/libs/maxiConvolve.cpp:26:35: error: no member named 'imag' in 'maxiFFT'
            imagVector.assign(fft.imag, fft.imag + fft.bins);
                              ~~~ ^
../../../src/libs/maxiConvolve.cpp:26:45: error: no member named 'imag' in 'maxiFFT'
            imagVector.assign(fft.imag, fft.imag + fft.bins);
                                        ~~~ ^
../../../src/libs/maxiConvolve.cpp:35:24: error: invalid operands to binary expression ('int' and 'void')
        for(int i=0; i < impulse.getLength(); i++) {
                     ~ ^ ~~~~~~~~~~~~~~~~~~~
../../../src/libs/maxiConvolve.cpp:40:58: error: invalid operands to binary expression ('void' and 'int')
        for(int i=0; i < fft.bins - (impulse.getLength() % fft.bins); i++) {
                                     ~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~
../../../src/libs/maxiConvolve.cpp:78:32: error: no member named 'real' in 'maxiFFT'
        realFrame.assign(inFFT.real, inFFT.real + inFFT.bins);
                         ~~~~~ ^
../../../src/libs/maxiConvolve.cpp:78:44: error: no member named 'real' in 'maxiFFT'
        realFrame.assign(inFFT.real, inFFT.real + inFFT.bins);
                                     ~~~~~ ^
../../../src/libs/maxiConvolve.cpp:83:32: error: no member named 'imag' in 'maxiFFT'
        imagFrame.assign(inFFT.imag, inFFT.imag + inFFT.bins);
                         ~~~~~ ^
../../../src/libs/maxiConvolve.cpp:83:44: error: no member named 'imag' in 'maxiFFT'
        imagFrame.assign(inFFT.imag, inFFT.imag + inFFT.bins);
                                     ~~~~~ ^
10 errors generated.

Live grammar editor

  1. add a third editor pane - just use the quickest method for now - maybe switchable via a button or tab with the ML javascript editor pane
  2. allow live editing of a grammar, with testing in the livecoding window
  3. keep everything in localstorage for now

Grammar editing usability

Can we clean up the javascript side to make things a bit easier for new users? e.g. replacing things like 'd => [{ "@num": d[0]}].concat(d[2])' with a named helper function.

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.