Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added example/sf_/sitar.sf2
Binary file not shown.
451 changes: 451 additions & 0 deletions example/src/OpenalDemo.cpp

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions example/src/alsademo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@

/*
https://www.linuxjournal.com/article/6735
This example reads standard from input and writes
to the default PCM device for 5 seconds of data.

put in example folder with main.c

maybe delete the .so fluidlite and use static or use "export LD_LIBRARY_PATH=./" before running and place with so file
gcc alsademo.c -L../../ -lfluidlite -lasound -lm -I../../include -o alsademo

*/

/* Use the newer ALSA API */
#define ALSA_PCM_NEW_HW_PARAMS_API

#include "fluidlite.h"
#include <alsa/asoundlib.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)

fluid_synth_t* synth;
float* flbuffer;
int audio_channels;

int main() {
long loops;
int rc;
int size;
snd_pcm_t *handle;
snd_pcm_hw_params_t *params;
unsigned int val;
int dir;
snd_pcm_uframes_t frames;
char *buffer;


//flstuff
audio_channels = 2;
fluid_settings_t* settings = new_fluid_settings();
synth = new_fluid_synth(settings);
// fluid_synth_sfload(synth, "../sf_/Boomwhacker.sf2", 1);
fluid_synth_sfload(synth, "../sf_/sitar.sf2", 1);
// fluid_synth_sfload(synth, "./soundfont.sf2", 1);
// flbuffer = (float *)calloc( SAMPLE_SIZE, NUM_SAMPLES );
float* flbuffer = calloc(SAMPLE_SIZE, NUM_SAMPLES);

fluid_synth_noteon(synth, 0, 80, 127);
// printf("triggered note\n");
fluid_synth_noteon(synth, 0, 60, 127);
printf("triggered note\n");
// fluid_synth_noteon(synth, 0, 60, 127);
// printf("triggered note\n");

/* Open PCM device for playback. */
rc = snd_pcm_open(&handle, "default",
SND_PCM_STREAM_PLAYBACK, 0);
if (rc < 0) {
fprintf(stderr,
"unable to open pcm device: %s\n",
snd_strerror(rc));
exit(1);
}

/* Allocate a hardware parameters object. */
snd_pcm_hw_params_alloca(&params);

/* Fill it in with default values. */
snd_pcm_hw_params_any(handle, params);

/* Set the desired hardware parameters. */

/* Interleaved mode */
snd_pcm_hw_params_set_access(handle, params,
SND_PCM_ACCESS_RW_INTERLEAVED);

/* Signed 16-bit little-endian format */
snd_pcm_hw_params_set_format(handle, params,
SND_PCM_FORMAT_S32_LE);

/* Two channels (stereo) */
snd_pcm_hw_params_set_channels(handle, params, 2);

/* 44100 bits/second sampling rate (CD quality) */
val = SAMPLE_RATE;
snd_pcm_hw_params_set_rate_near(handle, params,
&val, &dir);

/* Set period size to 32 frames. */
frames = 32;
snd_pcm_hw_params_set_period_size_near(handle,
params, &frames, &dir);

/* Write the parameters to the driver */
rc = snd_pcm_hw_params(handle, params);
if (rc < 0) {
fprintf(stderr,
"unable to set hw parameters: %s\n",
snd_strerror(rc));
exit(1);
}

/* Use a buffer large enough to hold one period */
snd_pcm_hw_params_get_period_size(params, &frames,
&dir);
size = SAMPLE_SIZE * 4; /* 2 bytes/sample, 2 channels */
buffer = (char *) malloc(size);

/* We want to loop for 5 seconds */
snd_pcm_hw_params_get_period_time(params,
&val, &dir);
/* 5 seconds in microseconds divided by
* period time */
loops = 1000 / val;


// time to loop the buffer 1 second
while (loops > 0) {
loops--;

fluid_synth_write_float(synth, NUM_SAMPLES, flbuffer, 0, audio_channels, flbuffer, 0, audio_channels );
rc = snd_pcm_writei(handle, flbuffer, NUM_FRAMES);

}

snd_pcm_drain(handle);
snd_pcm_close(handle);
free(buffer);

return 0;
}


65 changes: 65 additions & 0 deletions example/src/openaldemo.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Irrlicht Example 12 Terrain Rendering" />
<Option pch_mode="0" />
<Option compiler="gcc" />
<Build>
<Target title="Windows">
<Option platforms="Windows;" />
<Option output="../../bin/Win32-gcc/TerrainRendering" prefix_auto="0" extension_auto="1" />
<Option type="1" />
<Option compiler="gcc" />
<Option projectResourceIncludeDirsRelation="1" />
<Compiler>
<Add option="-g" />
</Compiler>
<Linker>
<Add directory="../../lib/Win32-gcc" />
</Linker>
</Target>
<Target title="Linux">
<Option platforms="Unix;" />
<Option output="../../bin/Linux/TerrainRendering" prefix_auto="0" extension_auto="0" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-w" />
<Add option="-std=gnu++17" />
<Add option="-g" />
<Add directory="../../../LunaLibs/irrlicht-1.8.4/include" />
<Add directory="/home/netpipe/Dev/LunaLibs/irrlicht-1.8.4/include" />
</Compiler>
<Linker>
<Add library="Xxf86vm" />
<Add library="X11" />
<Add library="GL" />
<Add library="fluidlite" />
<Add directory="../../lib/Linux" />
<Add directory="../../../LunaLibs/irrlicht-1.8.4/lib/Linux" />
<Add directory="/home/netpipe/Dev/LunaLibs/irrlicht-1.8.4/lib/Linux" />
<Add directory="../" />
<Add directory="../../" />
</Linker>
</Target>
</Build>
<VirtualTargets>
<Add alias="All" targets="Windows;Linux;" />
</VirtualTargets>
<Compiler>
<Add option="-g" />
<Add option="-DAgAudio2" />
<Add directory="../../include" />
</Compiler>
<Linker>
<Add library="Irrlicht" />
<Add library="openal" />
<Add library="ogg" />
<Add library="vorbis" />
<Add library="vorbisfile" />
</Linker>
<Unit filename="OpenalDemo.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>
25 changes: 25 additions & 0 deletions example/src/qFluidlite/.qmake.stash
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 5
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
QMAKE_CXX.COMPILER_MACROS = \
QT_COMPILER_STDCXX \
QMAKE_GCC_MAJOR_VERSION \
QMAKE_GCC_MINOR_VERSION \
QMAKE_GCC_PATCH_VERSION
QMAKE_CXX.INCDIRS = \
/usr/include/c++/7 \
/usr/include/c++/7/x86_64-suse-linux \
/usr/include/c++/7/backward \
/usr/lib64/gcc/x86_64-suse-linux/7/include \
/usr/local/include \
/usr/lib64/gcc/x86_64-suse-linux/7/include-fixed \
/usr/x86_64-suse-linux/include \
/usr/include
QMAKE_CXX.LIBDIRS = \
/usr/lib64/gcc/x86_64-suse-linux/7 \
/usr/lib64 \
/lib64 \
/usr/x86_64-suse-linux/lib \
/lib \
/usr/lib
84 changes: 84 additions & 0 deletions example/src/qFluidlite/Cow-Sync.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
QT += multimedia core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

#DEFINES += QT_DEPRECATED_WARNINGS

INCLUDEPATH += fluidlite/include

SOURCES += \
fluidlite/fluid_chan.c \
fluidlite/fluid_chorus.c \
fluidlite/fluid_conv.c \
fluidlite/fluid_defsfont.c \
fluidlite/fluid_dsp_float.c \
fluidlite/fluid_gen.c \
fluidlite/fluid_hash.c \
fluidlite/fluid_init.c \
fluidlite/fluid_list.c \
fluidlite/fluid_mod.c \
fluidlite/fluid_ramsfont.c \
fluidlite/fluid_rev.c \
fluidlite/fluid_settings.c \
fluidlite/fluid_synth.c \
fluidlite/fluid_sys.c \
fluidlite/fluid_tuning.c \
fluidlite/fluid_voice.c \
fluidlite/stb/stb_vorbis.c \
main.cpp \
mainwindow.cpp

HEADERS += \
fluidlite/fluid_chan.h \
fluidlite/fluid_chorus.h \
fluidlite/fluid_config.h \
fluidlite/fluid_conv.h \
fluidlite/fluid_defsfont.h \
fluidlite/fluid_gen.h \
fluidlite/fluid_hash.h \
fluidlite/fluid_list.h \
fluidlite/fluid_midi.h \
fluidlite/fluid_mod.h \
fluidlite/fluid_phase.h \
fluidlite/fluid_ramsfont.h \
fluidlite/fluid_rev.h \
fluidlite/fluid_settings.h \
fluidlite/fluid_sfont.h \
fluidlite/fluid_sys.h \
fluidlite/fluid_tuning.h \
fluidlite/fluid_voice.h \
fluidlite/fluidsynth_priv.h \
fluidlite/include/fluidlite.h \
fluidlite/include/fluidsynth/gen.h \
fluidlite/include/fluidsynth/log.h \
fluidlite/include/fluidsynth/misc.h \
fluidlite/include/fluidsynth/mod.h \
fluidlite/include/fluidsynth/ramsfont.h \
fluidlite/include/fluidsynth/settings.h \
fluidlite/include/fluidsynth/sfont.h \
fluidlite/include/fluidsynth/synth.h \
fluidlite/include/fluidsynth/types.h \
fluidlite/include/fluidsynth/version.h \
fluidlite/include/fluidsynth/voice.h \
mainwindow.h

FORMS += \
mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

DISTFILES += \
fluidlite/LICENSE \
fluidlite/Makefile.os2 \
fluidlite/README.md \
fluidlite/main.cbp \
fluidlite/soundfont.sf2
Loading