Git Product home page Git Product logo

opensfz's Introduction

OpenSFZ

An Open SFZ player & SF2 (Sampler) based on SFZero by Steve Folta ([email protected]), without the Juce dependency. SFZero resides at https://github.com/stevefolta/SFZero

Note, this is still in development and only has minimal functionality right now. Contributions to handle additional SFZ opcodes, more file formats, better resampling etc, are welcome.

Documentation and examples are coming soon.

Features

  • SF2 / SFZ playback
  • WAV / Ogg support (via stb_vorbis currently)

Planned:

  • Disk streaming (optional, but possibly with several different strategies)
  • More resampling options other than just Linear resampling
  • More sfz opcode support
  • Project files for Visual Studio (an XCode lib project exists currently)

License

This project is available under the MIT license.

Simple Example

#include "OpenSFZ.h"

....
// initialization:

    synth = new SFZSynth();
    
    SFZSound *testSound = new SFZSound(std::string("/Users/dwallin/Downloads/FM-House-Bass/FM-House-Bass.sfz"));

    synth->addSound(testSound);

    testSound->loadRegions();
    testSound->loadSamples();

    testSound->dump();    // print out debug info
    
    synth->setCurrentPlaybackSampleRate(SongInfo::getSampleRate());


// just handle midi events and call the appropriate functions on the SFZSynth class. 
// OpenSFZ doesn't have any midi specific code or classes. This is purely for example purposs.

    if(e->eventType == Event::EVENT_NOTEON)
    {
        // Note: Velocity should be in the 0...1 range, not the usual 1-127 midi range.
        synth->noteOn(1, e->iData[0], e->rData[0]);
    } else if(e->eventType == Event::EVENT_NOTEOFF)
    {
        synth->noteOff(1, e->iData[0], true);
    } else if(e->eventType == Event::EVENT_ALLNOTESOFF)
    {
        synth->allNotesOff(1, false);
    } else if(e->eventType == Event::EVENT_CC)
    {
        if(e->iData[0] == 121 || e->iData[0] == 123)
        {
            synth->allNotesOff(1, true);
        }
    }

// Audio processing. Call something like this in your audio processing callback loop: 
    // Note: audio buffers should be filled with zeros first

    SFZAudioBuffer buffer((int)numSamples,
                          audioOutLeftChannelPointer,
                          audioOutRightChannelPointer);
    
    synth->renderNextBlock(buffer, 0, (int)numSamples);
    
// that's it

opensfz's People

Contributors

whitenoise avatar

Watchers

 avatar

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.