Giter VIP home page Giter VIP logo

wmo's Introduction

Wave Magic Orchestra

A FM sound synthesis library

Description

This library replicates the functionality of an old school Yamaha synthesizer, i'm not aiming to perfection, or creating an emulator, i just want to create something that sounds good enough.
It uses FM synthesis (don't tell anyone, but it actually is PM) to simulate various instruments, 80's style.
Checkout an interface demonstrating what can be done with it, called WMO Operator.

Features (for now)

  • Up to 132 keys (on any desired frequency)
  • Up to 6 oscillators per key (can play as many keys as your CPU can handle)
  • Breakpoint / Level Scaling / Keyboard Tracking / Keyboard Following
  • Use one of the classic 4 and 6 operator algorithms
  • Load voices from SYSEX files (some settings can produce A LOT of noise or sound very different...)
  • Filters (high pass, low pass, band pass, distortion, etc...)

Note

WIP!

Basics

The idea is that you instantiate an Instrument, pass a Preset, and finally, press and release a key. Midi support is being worked on.
Presets can be obtained from DX7 sysex files using the Dx7Sysex utilitarian class, which reads bulk exported voices and returns a list of presets, one for each voice.
Audio is obtained via 16bit PCM samples, created by calling the one of the "getFrame" method variants (getByteFrame, getShortFrame, or getFloatFrame).

Example

This example utilizes Java AudioSystem to play the samples, it is a very basic use case.
See WMO Operator for another example, it uses LibGdx key press and release events to trigger the Instrument.

final List<InstrumentPreset> presetsList = Dx7Sysex.extractInstruments(new File("rom1a.syx"));
final Instrument instrument = new Instrument(44100);
instrument.setPreset(presetsList.get(20)); // preset 20 should be VIBES 1 on the cartridge dump used

/*
    we are creating a child thread because writing to the audio output is a blocking operation
    so we want this part to work without being bothered
*/
final Thread thread = new Thread(() -> {
    final AudioFormat audioFormat = new AudioFormat(44100, 16, 2, true, true);

    try (final SourceDataLine dataLine = AudioSystem.getSourceDataLine(audioFormat)) {
    
        // initializes the audio output
        dataLine.open(audioFormat);
        dataLine.start();
    
        // this blocks the thread, and have to be called as long as we want to play
        while (true) {
            // an audio frame have 4 bytes, 2 for each 16bit channel ([8bit L][8bit L]-[8bit R][8bit R])
            dataLine.write(instrument.getByteFrame(true), 0, 4);
        }
    } catch (LineUnavailableException e) {
        e.printStackTrace();
    }
});
thread.start();

// wait just a little for the audio initialization
Thread.sleep(500);

// this is from Stairway to Heaven intro
final KeyboardNote[] notes = new KeyboardNote[]{KeyboardNote.A_4, KeyboardNote.C_5, KeyboardNote.E_5, KeyboardNote.A_5, KeyboardNote.B_5};

// now we play then with 0.4s of duration, and 0.2s spacing
for(KeyboardNote note : notes){
    instrument.pressKey(note);
    Thread.sleep(400);
    instrument.releaseKey(note);
    Thread.sleep(200);
}

TODO

  • Proper README/documentation
  • A demo interface
  • Pitch envelope
  • Break points
  • Envelope rate/speed scaling
  • Transpose
  • Improve feedback
  • LFO
  • Filters running in parallel (aggregate the results of various filters, instead of just applying one filter after another)
  • Filter serialization
  • More filters
  • Channel separation/manipulation
  • Instrument presets
  • API fine tuning
  • Parameters fine tuning
  • MIDI support

wmo's People

Contributors

jbatistareis avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

yarnee

wmo's Issues

Question about polyphonic FM

I am trying to create three instruments and play them like this:
image
however, this creates a really bad whine. what is the preferred way of doing this, if there is one?

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.