Giter Site home page Giter Site logo

paulsapps / fluidlite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from divideconcept/fluidlite

0.0 1.0 0.0 1.07 MB

Very light version of FluidSynth designed to be hardware, platform and external dependency independant.

License: Other

C 98.61% C++ 0.97% Perl 0.13% CMake 0.19% Makefile 0.10%

fluidlite's Introduction

FluidLite

License: LGPL-2.1 Travis-CI Status

FluidLite (c) 2016 Robin Lobel

FluidLite is a very light version of FluidSynth designed to be hardware, platform and external dependency independant. It only uses standard C libraries.

It also adds support for SF3 files (SF2 files compressed with ogg vorbis) and an additional setting to remove the constraint of channel 9 (drums): fluid_settings_setstr(settings, "synth.drums-channel.active", "no"); you can still select bank 128 on any channel to use drum kits.

FluidLite keeps very minimal functionnalities (settings and synth), therefore MIDI file reading, realtime MIDI events and audio output must be implemented externally.

Config

By default SF3 support is disabled. To enable it use -DENABLE_SF3=YES with cmake.

Alternatively it can be configured to use stb_vorbis to decompress SF3 instead of Xiph's libogg/libvorbis. You can pass -DSTB_VORBIS=YES to cmake to do it.

Usage

#include <stdlib.h>
#include <stdio.h>

#include "fluidlite.h"

#define SAMPLE_RATE 44100
#define SAMPLE_SIZE sizeof(float)
#define NUM_FRAMES SAMPLE_RATE
#define NUM_CHANNELS 2
#define NUM_SAMPLES (NUM_FRAMES * NUM_CHANNELS)

int main() {
    fluid_settings_t* settings = new_fluid_settings();
    fluid_synth_t* synth = new_fluid_synth(settings);
    fluid_synth_sfload(synth, "soundfont.sf2", 1);

    float* buffer = calloc(SAMPLE_SIZE, NUM_SAMPLES);

    FILE* file = fopen("float32output.pcm", "wb");

    fluid_synth_noteon(synth, 0, 60, 127);
    fluid_synth_write_float(synth, NUM_FRAMES, buffer, 0, NUM_CHANNELS, buffer, 1, NUM_CHANNELS);
    fwrite(buffer, SAMPLE_SIZE, NUM_SAMPLES, file);

    fluid_synth_noteoff(synth, 0, 60);
    fluid_synth_write_float(synth, NUM_FRAMES, buffer, 0, NUM_CHANNELS, buffer, 1, NUM_CHANNELS);
    fwrite(buffer, SAMPLE_SIZE, NUM_SAMPLES, file);

    fclose(file);

    free(buffer);

    delete_fluid_synth(synth);
    delete_fluid_settings(settings);
}

fluidlite's People

Contributors

ccawley2011 avatar chouquette avatar divideconcept avatar ghabry avatar jpcima avatar katyo avatar korli avatar sezero avatar wallneradam 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.