├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── opensles
│ │ └── android
│ │ └── fluidsynth
│ │ └── fluidsynth_android_opensles
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── PNS Drum Kit.SF2
│ ├── cpp
│ │ ├── fluidsynth
│ │ │ ├── android
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── config.h
│ │ │ │ ├── include
│ │ │ │ │ └── fluidsynth
│ │ │ │ │ │ └── version.h
│ │ │ │ └── src
│ │ │ │ │ ├── bindings
│ │ │ │ │ └── fluid_cmd.c
│ │ │ │ │ └── drivers
│ │ │ │ │ ├── fluid_adriver.c
│ │ │ │ │ └── fluid_mdriver.c
│ │ │ ├── include
│ │ │ │ ├── fluidsynth.cmake
│ │ │ │ └── fluidsynth
│ │ │ │ │ ├── audio.h
│ │ │ │ │ ├── event.h
│ │ │ │ │ ├── gen.h
│ │ │ │ │ ├── ladspa.h
│ │ │ │ │ ├── log.h
│ │ │ │ │ ├── midi.h
│ │ │ │ │ ├── misc.h
│ │ │ │ │ ├── mod.h
│ │ │ │ │ ├── ramsfont.h
│ │ │ │ │ ├── seq.h
│ │ │ │ │ ├── seqbind.h
│ │ │ │ │ ├── settings.h
│ │ │ │ │ ├── sfont.h
│ │ │ │ │ ├── shell.h
│ │ │ │ │ ├── synth.h
│ │ │ │ │ ├── types.h
│ │ │ │ │ ├── version.h.in
│ │ │ │ │ └── voice.h
│ │ │ └── src
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── bindings
│ │ │ │ ├── fluid_cmd.c
│ │ │ │ ├── fluid_cmd.h
│ │ │ │ ├── fluid_filerenderer.c
│ │ │ │ ├── fluid_ladspa.c
│ │ │ │ ├── fluid_ladspa.h
│ │ │ │ ├── fluid_lash.c
│ │ │ │ ├── fluid_lash.h
│ │ │ │ ├── fluid_rtkit.c
│ │ │ │ └── fluid_rtkit.h
│ │ │ │ ├── config.cmake
│ │ │ │ ├── drivers
│ │ │ │ ├── fluid_adriver.c
│ │ │ │ ├── fluid_adriver.h
│ │ │ │ ├── fluid_alsa.c
│ │ │ │ ├── fluid_aufile.c
│ │ │ │ ├── fluid_coreaudio.c
│ │ │ │ ├── fluid_coremidi.c
│ │ │ │ ├── fluid_dart.c
│ │ │ │ ├── fluid_dsound.c
│ │ │ │ ├── fluid_jack.c
│ │ │ │ ├── fluid_mdriver.c
│ │ │ │ ├── fluid_mdriver.h
│ │ │ │ ├── fluid_midishare.c
│ │ │ │ ├── fluid_opensles.c
│ │ │ │ ├── fluid_oss.c
│ │ │ │ ├── fluid_portaudio.c
│ │ │ │ ├── fluid_pulse.c
│ │ │ │ ├── fluid_sndmgr.c
│ │ │ │ └── fluid_winmidi.c
│ │ │ │ ├── fluidsynth.c
│ │ │ │ ├── midi
│ │ │ │ ├── fluid_midi.c
│ │ │ │ ├── fluid_midi.h
│ │ │ │ ├── fluid_midi_router.c
│ │ │ │ ├── fluid_midi_router.h
│ │ │ │ ├── fluid_seq.c
│ │ │ │ └── fluid_seqbind.c
│ │ │ │ ├── rvoice
│ │ │ │ ├── fluid_adsr_env.c
│ │ │ │ ├── fluid_adsr_env.h
│ │ │ │ ├── fluid_chorus.c
│ │ │ │ ├── fluid_chorus.h
│ │ │ │ ├── fluid_iir_filter.c
│ │ │ │ ├── fluid_iir_filter.h
│ │ │ │ ├── fluid_lfo.c
│ │ │ │ ├── fluid_lfo.h
│ │ │ │ ├── fluid_phase.h
│ │ │ │ ├── fluid_rev.c
│ │ │ │ ├── fluid_rev.h
│ │ │ │ ├── fluid_rvoice.c
│ │ │ │ ├── fluid_rvoice.h
│ │ │ │ ├── fluid_rvoice_dsp.c
│ │ │ │ ├── fluid_rvoice_event.c
│ │ │ │ ├── fluid_rvoice_event.h
│ │ │ │ ├── fluid_rvoice_mixer.c
│ │ │ │ └── fluid_rvoice_mixer.h
│ │ │ │ ├── sfloader
│ │ │ │ ├── fluid_defsfont.c
│ │ │ │ ├── fluid_defsfont.h
│ │ │ │ ├── fluid_ramsfont.c
│ │ │ │ ├── fluid_ramsfont.h
│ │ │ │ ├── fluid_sfont.c
│ │ │ │ └── fluid_sfont.h
│ │ │ │ ├── synth
│ │ │ │ ├── fluid_chan.c
│ │ │ │ ├── fluid_chan.h
│ │ │ │ ├── fluid_event.c
│ │ │ │ ├── fluid_event_priv.h
│ │ │ │ ├── fluid_gen.c
│ │ │ │ ├── fluid_gen.h
│ │ │ │ ├── fluid_mod.c
│ │ │ │ ├── fluid_mod.h
│ │ │ │ ├── fluid_synth.c
│ │ │ │ ├── fluid_synth.h
│ │ │ │ ├── fluid_synth_monopoly.c
│ │ │ │ ├── fluid_tuning.c
│ │ │ │ ├── fluid_tuning.h
│ │ │ │ ├── fluid_voice.c
│ │ │ │ └── fluid_voice.h
│ │ │ │ └── utils
│ │ │ │ ├── fluid_atomic.h
│ │ │ │ ├── fluid_conv.c
│ │ │ │ ├── fluid_conv.h
│ │ │ │ ├── fluid_hash.c
│ │ │ │ ├── fluid_hash.h
│ │ │ │ ├── fluid_list.c
│ │ │ │ ├── fluid_list.h
│ │ │ │ ├── fluid_ringbuffer.c
│ │ │ │ ├── fluid_ringbuffer.h
│ │ │ │ ├── fluid_settings.c
│ │ │ │ ├── fluid_settings.h
│ │ │ │ ├── fluid_sys.c
│ │ │ │ ├── fluid_sys.h
│ │ │ │ └── fluidsynth_priv.h
│ │ └── native-lib.cpp
│ ├── java
│ │ └── opensles
│ │ │ └── android
│ │ │ └── fluidsynth
│ │ │ └── fluidsynth_android_opensles
│ │ │ ├── MainActivity.kt
│ │ │ └── NativeLibJNI.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── opensles
│ └── android
│ └── fluidsynth
│ └── fluidsynth_android_opensles
│ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # IDEA
2 | *.iml
3 | /.idea
4 | !/.idea/runConfigurations
5 |
6 | # Gradle
7 | .gradle
8 | build
9 | /reports
10 |
11 | # Gradle Android
12 | /local.properties
13 | /captures
14 |
15 | # OSX
16 | .DS_Store
17 |
18 | .externalNativeBuild
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # fluidsynth-android-opensles
2 | This is a sample project which strives to use fluidsynth as a native android library with OpenSL ES support
3 |
4 |
5 | The original fluidsynth repository can be found here: [FluidSynth/fluidsynth](https://github.com/FluidSynth/fluidsynth)
6 |
7 | Adjustments, or better yet additions, to build fluidsynth for the Android platform where made by VolcanoMobile in this repository: [VolcanoMobile/fluidsynth-android](https://github.com/VolcanoMobile/fluidsynth-android)
8 |
9 | I set up a fresh Android project via AndroidStudio, simply copied over all relevant files from [VolcanoMobile/fluidsynth-android](https://github.com/VolcanoMobile/fluidsynth-android) and referenced the `android/CMakeLists.txt` within the app's `build.gradle`. That works in the sense that it compiles and fluidsynth can be used within the app (i.e. JNI). But in order to be able to build fluidsynth for Android VolcanoMobile exluded all Audio-Driver classes, thus removing the ability to actually hear any MIDI events.
10 |
11 | To enable audio with fluidsynth on Android with the OpenSL ES audio framework [atsushieno](https://github.com/atsushieno) made independent changes to fluidsynth in his own fluidsynth [fork](https://github.com/atsushieno/fluidsynth). I was not able to build that project. But, since I was able to build VolcanoMobiles version of fluidsynth I thought it might be possible to only include atsushienos changes into VolcanoMobiles version. This project tries to do exactly that.
12 |
13 | **NOTE**:
14 | I know that this project currently scrambles fluidsynth library code with sample app code. I wanted to extract the fluidsynth part into it's own gradle-module library inside this project and have another module (i.e. the android sample app) with it's own native code use that library. But I couldn't get it to work. The native code inside the sample app then couldn't find the headers provided by the fluidsynth library. Any ideas are welcome.
15 |
16 |
17 | ## Progress:
18 | * [X] Include VolcanoMobiles version of [fluidsynth](https://github.com/VolcanoMobile/fluidsynth-android)
19 | * [X] Include atsushienos additions to fluidsynth to enable OpenSL ES support. His changes can be found in this [patch](https://gist.github.com/atsushieno/539e4e14d4eafcad724e446ad73dc1ad)
20 | * [X] Be able to build the project again. Update: It now builds with changes taken from [here](https://github.com/atsushieno/fluidsynth/issues/8#issuecomment-371875875) and [here](https://gist.github.com/atsushieno/950eb50626e0009d5e919588a0ca9ef9).
21 | * [ ] Extract the fluidsynth part into its own gradle-module and have a sample app reference it
22 | * [ ] Fix `W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT)`. After a while the output stumbles and logcat is filled with this log statement.
23 |
24 | ## Acknowledgements
25 | - [FluidSynth](https://github.com/FluidSynth/) for open sourcing [fluidsynth](https://github.com/FluidSynth/fluidsynth)
26 | - [VolcanoMobile](https://github.com/VolcanoMobile/) for getting fluidsynth to build on android in this [fork: fluidsynth-android](https://github.com/VolcanoMobile/fluidsynth-android)
27 | - [atsushieno](https://github.com/atsushieno) for implementing an audio driver in fluidsynth using OpenSL ES on android in his own fork of fluidsynth. All of the used changes by him can be found in this [issue](https://github.com/atsushieno/fluidsynth/issues/8)
28 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 26
9 | defaultConfig {
10 | applicationId "opensles.android.fluidsynth.fluidsynth_android_opensles"
11 | minSdkVersion 21
12 | targetSdkVersion 26
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | externalNativeBuild {
17 | cmake {
18 | cppFlags ""
19 | }
20 | }
21 | }
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | externalNativeBuild {
29 | cmake {
30 | path "src/main/cpp/fluidsynth/android/CMakeLists.txt"
31 | }
32 | }
33 | }
34 |
35 | dependencies {
36 | implementation fileTree(dir: 'libs', include: ['*.jar'])
37 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
38 | implementation 'com.android.support:appcompat-v7:26.1.0'
39 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
40 | implementation 'com.squareup.okio:okio:1.14.0'
41 | testImplementation 'junit:junit:4.12'
42 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
43 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
44 | }
45 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/opensles/android/fluidsynth/fluidsynth_android_opensles/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package opensles.android.fluidsynth.fluidsynth_android_opensles
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("opensles.android.fluidsynth.fluidsynth_android_opensles", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/assets/PNS Drum Kit.SF2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/assets/PNS Drum Kit.SF2
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/android/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.4.1)
2 |
3 | set(src_DIR ../src)
4 |
5 | set(fluidsynth_sources
6 | ${src_DIR}/midi/fluid_midi.c
7 | ${src_DIR}/midi/fluid_midi_router.c
8 | ${src_DIR}/midi/fluid_seq.c
9 | ${src_DIR}/midi/fluid_seqbind.c
10 | ${src_DIR}/rvoice/fluid_adsr_env.c
11 | ${src_DIR}/rvoice/fluid_chorus.c
12 | ${src_DIR}/rvoice/fluid_iir_filter.c
13 | ${src_DIR}/rvoice/fluid_lfo.c
14 | ${src_DIR}/rvoice/fluid_rev.c
15 | ${src_DIR}/rvoice/fluid_rvoice.c
16 | ${src_DIR}/rvoice/fluid_rvoice_dsp.c
17 | ${src_DIR}/rvoice/fluid_rvoice_event.c
18 | ${src_DIR}/rvoice/fluid_rvoice_mixer.c
19 | ${src_DIR}/sfloader/fluid_defsfont.c
20 | ${src_DIR}/sfloader/fluid_ramsfont.c
21 | ${src_DIR}/sfloader/fluid_sfont.c
22 | ${src_DIR}/synth/fluid_chan.c
23 | ${src_DIR}/synth/fluid_event.c
24 | ${src_DIR}/synth/fluid_gen.c
25 | ${src_DIR}/synth/fluid_mod.c
26 | ${src_DIR}/synth/fluid_synth.c
27 | ${src_DIR}/synth/fluid_tuning.c
28 | ${src_DIR}/synth/fluid_voice.c
29 | ${src_DIR}/synth/fluid_synth_monopoly.c
30 | ${src_DIR}/utils/fluid_conv.c
31 | ${src_DIR}/utils/fluid_hash.c
32 | ${src_DIR}/utils/fluid_list.c
33 | ${src_DIR}/utils/fluid_ringbuffer.c
34 | ${src_DIR}/utils/fluid_settings.c
35 | ${src_DIR}/bindings/fluid_filerenderer.c
36 | ${src_DIR}/drivers/fluid_adriver.c
37 | ${src_DIR}/drivers/fluid_opensles.c
38 | ${src_DIR}/utils/fluid_sys.c
39 | src/bindings/fluid_cmd.c
40 | src/drivers/fluid_mdriver.c
41 | ../../native-lib.cpp # This line needs to be removed; It's only for testing purposes
42 | )
43 |
44 | set ( public_main_HEADER
45 | ${CMAKE_BINARY_DIR}/include/fluidsynth.h
46 | )
47 |
48 | configure_file ( ../include/fluidsynth.cmake
49 | ${public_main_HEADER} )
50 |
51 | add_library(fluidsynth SHARED ${fluidsynth_sources})
52 |
53 | if(ANDROID_ABI STREQUAL "armeabi-v7a")
54 | target_compile_options(fluidsynth PRIVATE -DWITH_FLOAT)
55 | endif()
56 | if(ANDROID_ABI STREQUAL "x86")
57 | target_compile_options(fluidsynth PRIVATE -DWITH_FLOAT)
58 | endif()
59 |
60 | # Specify directories which the compiler should look for headers
61 | target_include_directories(fluidsynth PRIVATE
62 | . include
63 | ${src_DIR}/../include
64 | ${src_DIR}/synth
65 | ${src_DIR}/midi
66 | ${src_DIR}/rvoice
67 | ${src_DIR}/sfloader
68 | ${src_DIR}/utils
69 | ${src_DIR}/bindings
70 | ${src_DIR}/drivers
71 | ${CMAKE_BINARY_DIR}/include
72 | )
73 |
74 | target_include_directories(fluidsynth INTERFACE
75 | . include
76 | ${src_DIR}/../include
77 | ${CMAKE_BINARY_DIR}/include
78 | )
79 |
80 | target_compile_options(fluidsynth
81 | PRIVATE -Wall
82 | PRIVATE -DHAVE_CONFIG_H
83 | PRIVATE -Wno-unused-variable
84 | PRIVATE "$<$:-Werror>") # Only include -Werror when building debug config
85 |
86 | target_link_libraries (fluidsynth OpenSLES log)
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/android/config.h:
--------------------------------------------------------------------------------
1 | #ifndef CONFIG_H
2 | #define CONFIG_H
3 |
4 | /* Define to enable ALSA driver */
5 | /* #undef ALSA_SUPPORT */
6 |
7 | /* Define to activate sound output to files */
8 | /* #undef AUFILE_SUPPORT */
9 |
10 | /* whether or not we are supporting CoreAudio */
11 | /* #undef COREAUDIO_SUPPORT */
12 |
13 | /* whether or not we are supporting CoreMIDI */
14 | /* #undef COREMIDI_SUPPORT */
15 |
16 | /* whether or not we are supporting DART */
17 | /* #undef DART_SUPPORT */
18 |
19 | /* Define if building for Mac OS X Darwin */
20 | /* #undef DARWIN */
21 |
22 | /* Define if D-Bus support is enabled */
23 | /* #undef DBUS_SUPPORT */
24 |
25 | /* Define to enable FPE checks */
26 | /* #undef FPE_CHECK */
27 |
28 | /* Define to 1 if you have the header file. */
29 | /*#undef HAVE_ARPA_INET_H */
30 |
31 | /* Define to 1 if you have the header file. */
32 | #define HAVE_DLFCN_H 1
33 |
34 | /* Define to 1 if you have the header file. */
35 | #define HAVE_ERRNO_H 1
36 |
37 | /* Define to 1 if you have the header file. */
38 | #define HAVE_FCNTL_H 1
39 |
40 | /* Define to 1 if you have the header file. */
41 | #define HAVE_INTTYPES_H 1
42 |
43 | /* whether or not we are supporting ladcca */
44 | /* #undef HAVE_LADCCA */
45 |
46 | /* whether or not we are supporting lash */
47 | /* #undef HAVE_LASH */
48 |
49 | /* Define to 1 if you have the `dl' library (-ldl). */
50 | /* #undef HAVE_LIBDL */
51 |
52 | /* Define to 1 if you have the `MidiShare' library (-lMidiShare). */
53 | /* #undef HAVE_LIBMIDISHARE */
54 |
55 | /* Define to 1 if you have the `pthread' library (-lpthread). */
56 | #define HAVE_LIBPTHREAD TRUE
57 |
58 | /* Define to 1 if you have the header file. */
59 | #define HAVE_LIMITS_H 1
60 |
61 | /* Define to 1 if you have the header file. */
62 | /* #undef HAVE_MACHINE_SOUNDCARD_H */
63 |
64 | /* Define to 1 if you have the header file. */
65 | #define HAVE_MATH_H 1
66 |
67 | /* Define to 1 if you have the header file. */
68 | #define HAVE_MEMORY_H 1
69 |
70 | /* Define to 1 if you have the header file. */
71 | /* #undef HAVE_MIDISHARE_H */
72 |
73 | /* Define to 1 if you have the header file. */
74 | #define HAVE_NETINET_IN_H 1
75 |
76 | /* Define to 1 if you have the header file. */
77 | #define HAVE_NETINET_TCP_H 1
78 |
79 | /* Define to 1 if you have the header file. */
80 | #define HAVE_PTHREAD_H 1
81 |
82 | /* Define to 1 if you have the header file. */
83 | #define HAVE_SIGNAL_H 1
84 |
85 | /* Define to 1 if you have the header file. */
86 | #define HAVE_STDARG_H 1
87 |
88 | /* Define to 1 if you have the header file. */
89 | #define HAVE_STDINT_H 1
90 |
91 | /* Define to 1 if you have the header file. */
92 | #define HAVE_STDIO_H 1
93 |
94 | /* Define to 1 if you have the header file. */
95 | #define HAVE_STDLIB_H 1
96 |
97 | /* Define to 1 if you have the header file. */
98 | #define HAVE_STRINGS_H 1
99 |
100 | /* Define to 1 if you have the header file. */
101 | #define HAVE_STRING_H 1
102 |
103 | /* Define to 1 if you have the header file. */
104 | #define HAVE_SYS_IOCTL_H 1
105 |
106 | /* Define to 1 if you have the header file. */
107 | /* #undef HAVE_SYS_MMAN_H */
108 |
109 | /* Define to 1 if you have the header file. */
110 | #define HAVE_SYS_SOCKET_H 1
111 |
112 | /* Define to 1 if you have the header file. */
113 | #define HAVE_NETINET_IN_H 1
114 |
115 | /* Define to 1 if you have the header file. */
116 | #define HAVE_NETINET_TCP_H 1
117 |
118 | /* Define to 1 if you have the header file. */
119 | #define HAVE_ARPA_INET_H 1
120 |
121 | /* Define to 1 if you have the header file. */
122 | /* #undef HAVE_SYS_SOUNDCARD_H */
123 |
124 | /* Define to 1 if you have the header file. */
125 | #define HAVE_SYS_STAT_H 1
126 |
127 | /* Define to 1 if you have the header file. */
128 | #define HAVE_SYS_TIME_H 1
129 |
130 | /* Define to 1 if you have the header file. */
131 | #define HAVE_SYS_TYPES_H 1
132 |
133 | /* Define to 1 if you have the header file. */
134 | #define HAVE_UNISTD_H 1
135 |
136 | /* Define to 1 if you have the header file. */
137 | /* #undef HAVE_WINDOWS_H */
138 |
139 | /* Define to 1 if you have the header file. */
140 | #define HAVE_GETOPT_H 1
141 |
142 | /* Define to enable JACK driver */
143 | /* #undef JACK_SUPPORT */
144 |
145 | /* Include the LADSPA Fx unit */
146 | /* #undef LADSPA */
147 |
148 | /* libsndfile has ogg vorbis support */
149 | /* #undef LIBSNDFILE_HASVORBIS */
150 |
151 | /* Define to enable libsndfile support */
152 | /* #undef LIBSNDFILE_SUPPORT */
153 |
154 | /* Define to enable MidiShare driver */
155 | /* #undef MIDISHARE_SUPPORT */
156 |
157 | /* Define if using the MinGW32 environment */
158 | /* #undef MINGW32 */
159 |
160 | /* Define to 1 if your C compiler doesn't accept -c and -o together. */
161 | /* #undef NO_MINUS_C_MINUS_O */
162 |
163 | /* Define to enable OSS driver */
164 | /* #undef OSS_SUPPORT */
165 |
166 | /* Name of package */
167 | #define PACKAGE "fluidsynth"
168 |
169 | /* Define to the address where bug reports for this package should be sent. */
170 | /* #undef PACKAGE_BUGREPORT */
171 |
172 | /* Define to the full name of this package. */
173 | /* #undef PACKAGE_NAME */
174 |
175 | /* Define to the full name and version of this package. */
176 | /* #undef PACKAGE_STRING */
177 |
178 | /* Define to the one symbol short name of this package. */
179 | /* #undef PACKAGE_TARNAME */
180 |
181 | /* Define to the version of this package. */
182 | /* #undef PACKAGE_VERSION */
183 |
184 | /* Define to enable PortAudio driver */
185 | /* #undef PORTAUDIO_SUPPORT */
186 |
187 | /* Define to enable PulseAudio driver */
188 | /* #undef PULSE_SUPPORT */
189 |
190 | /* Define to 1 if you have the ANSI C header files. */
191 | #define STDC_HEADERS 1
192 |
193 | /* Define to enable SIGFPE assertions */
194 | /* #undef TRAP_ON_FPE */
195 |
196 | /* Version number of package */
197 | #define VERSION "1.1.9"
198 |
199 | /* Define to do all DSP in single floating point precision */
200 | /* #undef WITH_FLOAT */
201 |
202 | /* Define to profile the DSP code */
203 | /* #undef WITH_PROFILING */
204 |
205 | /* Define to use the readline library for line editing */
206 | /* #undef WITH_READLINE */
207 |
208 | /* Define if the compiler supports VLA */
209 | #define SUPPORTS_VLA
210 |
211 | /* Define to 1 if your processor stores words with the most significant byte
212 | first (like Motorola and SPARC, unlike Intel and VAX). */
213 | /* #undef WORDS_BIGENDIAN */
214 |
215 | /* Define to `__inline__' or `__inline' if that's what the C compiler
216 | calls it, or to nothing if 'inline' is not supported under any name. */
217 | #ifndef __cplusplus
218 | /* #undef inline */
219 | #endif
220 |
221 | #endif /* CONFIG_H */
222 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/android/include/fluidsynth/version.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Library General Public License
7 | * as published by the Free Software Foundation; either version 2 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Library General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Library General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_VERSION_H
22 | #define _FLUIDSYNTH_VERSION_H
23 |
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /**
30 | * @file version.h
31 | * @brief Library version functions and defines
32 | */
33 |
34 | #define FLUIDSYNTH_VERSION "1.1.9" /**< String constant of libfluidsynth version. */
35 | #define FLUIDSYNTH_VERSION_MAJOR 1 /**< libfluidsynth major version integer constant. */
36 | #define FLUIDSYNTH_VERSION_MINOR 1 /**< libfluidsynth minor version integer constant. */
37 | #define FLUIDSYNTH_VERSION_MICRO 9 /**< libfluidsynth micro version integer constant. */
38 |
39 | FLUIDSYNTH_API void fluid_version(int *major, int *minor, int *micro);
40 | FLUIDSYNTH_API char* fluid_version_str(void);
41 |
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 |
47 | #endif /* _FLUIDSYNTH_VERSION_H */
48 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/android/src/bindings/fluid_cmd.c:
--------------------------------------------------------------------------------
1 | #include "fluid_synth.h"
2 | #include "fluid_settings.h"
3 |
4 | void fluid_shell_settings(fluid_settings_t* settings)
5 | {
6 | // NOOP
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/android/src/drivers/fluid_adriver.c:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #include "fluid_adriver.h"
22 | #include "fluid_settings.h"
23 |
24 | void fluid_audio_driver_settings(fluid_settings_t* settings)
25 | {
26 | // NOOP
27 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/android/src/drivers/fluid_mdriver.c:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #include "fluid_mdriver.h"
22 | #include "fluid_settings.h"
23 |
24 | void fluid_midi_driver_settings(fluid_settings_t* settings)
25 | {
26 | // NOOP
27 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth.cmake:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_H
22 | #define _FLUIDSYNTH_H
23 |
24 | #include
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | #cmakedefine01 BUILD_SHARED_LIBS
31 |
32 | #if (BUILD_SHARED_LIBS == 0)
33 | #define FLUIDSYNTH_API // building static lib? no visibility control then
34 | #elif defined(WIN32)
35 | #if defined(FLUIDSYNTH_NOT_A_DLL)
36 | #define FLUIDSYNTH_API
37 | #elif defined(FLUIDSYNTH_DLL_EXPORTS)
38 | #define FLUIDSYNTH_API __declspec(dllexport)
39 | #else
40 | #define FLUIDSYNTH_API __declspec(dllimport)
41 | #endif
42 |
43 | #elif defined(MACOS9)
44 | #define FLUIDSYNTH_API __declspec(export)
45 |
46 | #elif defined(__GNUC__)
47 | #define FLUIDSYNTH_API __attribute__ ((visibility ("default")))
48 |
49 | #else
50 | #define FLUIDSYNTH_API
51 |
52 | #endif
53 |
54 | #if defined(__GNUC__) || defined(__clang__)
55 | # define FLUID_DEPRECATED __attribute__((deprecated))
56 | #elif defined(_MSC_VER) && _MSC_VER > 1200
57 | # define FLUID_DEPRECATED __declspec(deprecated)
58 | #else
59 | # define FLUID_DEPRECATED
60 | #endif
61 |
62 |
63 | /**
64 | * @file fluidsynth.h
65 | * @brief FluidSynth is a real-time synthesizer designed for SoundFont(R) files.
66 | *
67 | * This is the header of the fluidsynth library and contains the
68 | * synthesizer's public API.
69 | *
70 | * Depending on how you want to use or extend the synthesizer you
71 | * will need different API functions. You probably do not need all
72 | * of them. Here is what you might want to do:
73 | *
74 | * - Embedded synthesizer: create a new synthesizer and send MIDI
75 | * events to it. The sound goes directly to the audio output of
76 | * your system.
77 | *
78 | * - Plugin synthesizer: create a synthesizer and send MIDI events
79 | * but pull the audio back into your application.
80 | *
81 | * - SoundFont plugin: create a new type of "SoundFont" and allow
82 | * the synthesizer to load your type of SoundFonts.
83 | *
84 | * - MIDI input: Create a MIDI handler to read the MIDI input on your
85 | * machine and send the MIDI events directly to the synthesizer.
86 | *
87 | * - MIDI files: Open MIDI files and send the MIDI events to the
88 | * synthesizer.
89 | *
90 | * - Command lines: You can send textual commands to the synthesizer.
91 | *
92 | * SoundFont(R) is a registered trademark of E-mu Systems, Inc.
93 | */
94 |
95 | #include "fluidsynth/types.h"
96 | #include "fluidsynth/settings.h"
97 | #include "fluidsynth/synth.h"
98 | #include "fluidsynth/shell.h"
99 | #include "fluidsynth/sfont.h"
100 | #include "fluidsynth/ramsfont.h"
101 | #include "fluidsynth/audio.h"
102 | #include "fluidsynth/event.h"
103 | #include "fluidsynth/midi.h"
104 | #include "fluidsynth/seq.h"
105 | #include "fluidsynth/seqbind.h"
106 | #include "fluidsynth/log.h"
107 | #include "fluidsynth/misc.h"
108 | #include "fluidsynth/mod.h"
109 | #include "fluidsynth/gen.h"
110 | #include "fluidsynth/voice.h"
111 | #include "fluidsynth/version.h"
112 | #include "fluidsynth/ladspa.h"
113 |
114 |
115 | #ifdef __cplusplus
116 | }
117 | #endif
118 |
119 | #endif /* _FLUIDSYNTH_H */
120 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/audio.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_AUDIO_H
22 | #define _FLUIDSYNTH_AUDIO_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /**
29 | * @file audio.h
30 | * @brief Functions for audio driver output.
31 | * @defgroup AudioFunctions Functions for audio output
32 | *
33 | * Defines functions for creating audio driver output. Use
34 | * new_fluid_audio_driver() to create a new audio driver for a given synth
35 | * and configuration settings. The function new_fluid_audio_driver2() can be
36 | * used if custom audio processing is desired before the audio is sent to the
37 | * audio driver (although it is not as efficient).
38 | *
39 | * @sa @ref CreatingAudioDriver
40 | */
41 |
42 | /**
43 | * Callback function type used with new_fluid_audio_driver2() to allow for
44 | * custom user audio processing before the audio is sent to the driver. This
45 | * function is responsible for rendering the audio to the buffers.
46 | * @param data The user data parameter as passed to new_fluid_audio_driver2().
47 | * @param len Length of the audio in frames.
48 | * @param nin Count of buffers in 'in'
49 | * @param in Not used currently
50 | * @param nout Count of arrays in 'out' (i.e., channel count)
51 | * @param out Output buffers, one for each channel
52 | * @return Should return 0 on success, non-zero if an error occured.
53 | */
54 | typedef int (*fluid_audio_func_t)(void* data, int len,
55 | int nin, float** in,
56 | int nout, float** out);
57 |
58 | FLUIDSYNTH_API fluid_audio_driver_t* new_fluid_audio_driver(fluid_settings_t* settings,
59 | fluid_synth_t* synth);
60 |
61 | FLUIDSYNTH_API fluid_audio_driver_t* new_fluid_audio_driver2(fluid_settings_t* settings,
62 | fluid_audio_func_t func,
63 | void* data);
64 |
65 | FLUIDSYNTH_API void delete_fluid_audio_driver(fluid_audio_driver_t* driver);
66 |
67 | FLUIDSYNTH_API fluid_file_renderer_t *new_fluid_file_renderer(fluid_synth_t* synth);
68 | FLUIDSYNTH_API int fluid_file_renderer_process_block(fluid_file_renderer_t* dev);
69 | FLUIDSYNTH_API void delete_fluid_file_renderer(fluid_file_renderer_t* dev);
70 | FLUIDSYNTH_API int fluid_file_set_encoding_quality(fluid_file_renderer_t* dev, double q);
71 |
72 | FLUIDSYNTH_API int fluid_audio_driver_register(const char** adrivers);
73 |
74 | #ifdef __cplusplus
75 | }
76 | #endif
77 |
78 | #endif /* _FLUIDSYNTH_AUDIO_H */
79 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/event.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_EVENT_H
22 | #define _FLUIDSYNTH_EVENT_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /**
29 | * @file event.h
30 | * @brief Sequencer event functions and defines.
31 | *
32 | * Functions and constants for creating/processing sequencer events.
33 | */
34 |
35 | /**
36 | * Sequencer event type enumeration.
37 | */
38 | enum fluid_seq_event_type {
39 | FLUID_SEQ_NOTE = 0, /**< Note event with duration */
40 | FLUID_SEQ_NOTEON, /**< Note on event */
41 | FLUID_SEQ_NOTEOFF, /**< Note off event */
42 | FLUID_SEQ_ALLSOUNDSOFF, /**< All sounds off event */
43 | FLUID_SEQ_ALLNOTESOFF, /**< All notes off event */
44 | FLUID_SEQ_BANKSELECT, /**< Bank select message */
45 | FLUID_SEQ_PROGRAMCHANGE, /**< Program change message */
46 | FLUID_SEQ_PROGRAMSELECT, /**< Program select message */
47 | FLUID_SEQ_PITCHBEND, /**< Pitch bend message */
48 | FLUID_SEQ_PITCHWHEELSENS, /**< Pitch wheel sensitivity set message @since 1.1.0 was mispelled previously */
49 | FLUID_SEQ_MODULATION, /**< Modulation controller event */
50 | FLUID_SEQ_SUSTAIN, /**< Sustain controller event */
51 | FLUID_SEQ_CONTROLCHANGE, /**< MIDI control change event */
52 | FLUID_SEQ_PAN, /**< Stereo pan set event */
53 | FLUID_SEQ_VOLUME, /**< Volume set event */
54 | FLUID_SEQ_REVERBSEND, /**< Reverb send set event */
55 | FLUID_SEQ_CHORUSSEND, /**< Chorus send set event */
56 | FLUID_SEQ_TIMER, /**< Timer event (useful for giving a callback at a certain time) */
57 | FLUID_SEQ_ANYCONTROLCHANGE, /**< Any control change message (only internally used for remove_events) */
58 | FLUID_SEQ_CHANNELPRESSURE, /**< Channel aftertouch event @since 1.1.0 */
59 | FLUID_SEQ_KEYPRESSURE, /**< Polyphonic aftertouch event @since 2.0.0 */
60 | FLUID_SEQ_SYSTEMRESET, /**< System reset event @since 1.1.0 */
61 | FLUID_SEQ_UNREGISTERING, /**< Called when a sequencer client is being unregistered. @since 1.1.0 */
62 | #ifndef __DOXYGEN__
63 | FLUID_SEQ_LASTEVENT /**< @internal Defines the count of events enums @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */
64 | #endif
65 | };
66 |
67 | /* Event alloc/free */
68 | FLUIDSYNTH_API fluid_event_t* new_fluid_event(void);
69 | FLUIDSYNTH_API void delete_fluid_event(fluid_event_t* evt);
70 |
71 | /* Initializing events */
72 | FLUIDSYNTH_API void fluid_event_set_source(fluid_event_t* evt, fluid_seq_id_t src);
73 | FLUIDSYNTH_API void fluid_event_set_dest(fluid_event_t* evt, fluid_seq_id_t dest);
74 |
75 | /* Timer events */
76 | FLUIDSYNTH_API void fluid_event_timer(fluid_event_t* evt, void* data);
77 |
78 | /* Note events */
79 | FLUIDSYNTH_API void fluid_event_note(fluid_event_t* evt, int channel,
80 | short key, short vel,
81 | unsigned int duration);
82 |
83 | FLUIDSYNTH_API void fluid_event_noteon(fluid_event_t* evt, int channel, short key, short vel);
84 | FLUIDSYNTH_API void fluid_event_noteoff(fluid_event_t* evt, int channel, short key);
85 | FLUIDSYNTH_API void fluid_event_all_sounds_off(fluid_event_t* evt, int channel);
86 | FLUIDSYNTH_API void fluid_event_all_notes_off(fluid_event_t* evt, int channel);
87 |
88 | /* Instrument selection */
89 | FLUIDSYNTH_API void fluid_event_bank_select(fluid_event_t* evt, int channel, short bank_num);
90 | FLUIDSYNTH_API void fluid_event_program_change(fluid_event_t* evt, int channel, short preset_num);
91 | FLUIDSYNTH_API void fluid_event_program_select(fluid_event_t* evt, int channel, unsigned int sfont_id, short bank_num, short preset_num);
92 |
93 | /* Real-time generic instrument controllers */
94 | FLUIDSYNTH_API
95 | void fluid_event_control_change(fluid_event_t* evt, int channel, short control, short val);
96 |
97 | /* Real-time instrument controllers shortcuts */
98 | FLUIDSYNTH_API void fluid_event_pitch_bend(fluid_event_t* evt, int channel, int val);
99 | FLUIDSYNTH_API void fluid_event_pitch_wheelsens(fluid_event_t* evt, int channel, short val);
100 | FLUIDSYNTH_API void fluid_event_modulation(fluid_event_t* evt, int channel, short val);
101 | FLUIDSYNTH_API void fluid_event_sustain(fluid_event_t* evt, int channel, short val);
102 | FLUIDSYNTH_API void fluid_event_pan(fluid_event_t* evt, int channel, short val);
103 | FLUIDSYNTH_API void fluid_event_volume(fluid_event_t* evt, int channel, short val);
104 | FLUIDSYNTH_API void fluid_event_reverb_send(fluid_event_t* evt, int channel, short val);
105 | FLUIDSYNTH_API void fluid_event_chorus_send(fluid_event_t* evt, int channel, short val);
106 |
107 | FLUIDSYNTH_API void fluid_event_key_pressure(fluid_event_t* evt, int channel, short key, short val);
108 | FLUIDSYNTH_API void fluid_event_channel_pressure(fluid_event_t* evt, int channel, short val);
109 | FLUIDSYNTH_API void fluid_event_system_reset(fluid_event_t* evt);
110 |
111 |
112 | /* Only for removing events */
113 | FLUIDSYNTH_API void fluid_event_any_control_change(fluid_event_t* evt, int channel);
114 |
115 | /* Only when unregistering clients */
116 | FLUIDSYNTH_API void fluid_event_unregistering(fluid_event_t* evt);
117 |
118 | /* Accessing event data */
119 | FLUIDSYNTH_API int fluid_event_get_type(fluid_event_t* evt);
120 | FLUIDSYNTH_API fluid_seq_id_t fluid_event_get_source(fluid_event_t* evt);
121 | FLUIDSYNTH_API fluid_seq_id_t fluid_event_get_dest(fluid_event_t* evt);
122 | FLUIDSYNTH_API int fluid_event_get_channel(fluid_event_t* evt);
123 | FLUIDSYNTH_API short fluid_event_get_key(fluid_event_t* evt);
124 | FLUIDSYNTH_API short fluid_event_get_velocity(fluid_event_t* evt);
125 | FLUIDSYNTH_API short fluid_event_get_control(fluid_event_t* evt);
126 | FLUIDSYNTH_API short fluid_event_get_value(fluid_event_t* evt);
127 | FLUIDSYNTH_API short fluid_event_get_program(fluid_event_t* evt);
128 | FLUIDSYNTH_API void* fluid_event_get_data(fluid_event_t* evt);
129 | FLUIDSYNTH_API unsigned int fluid_event_get_duration(fluid_event_t* evt);
130 | FLUIDSYNTH_API short fluid_event_get_bank(fluid_event_t* evt);
131 | FLUIDSYNTH_API int fluid_event_get_pitch(fluid_event_t* evt);
132 | FLUIDSYNTH_API unsigned int fluid_event_get_sfont_id(fluid_event_t* evt);
133 |
134 | #ifdef __cplusplus
135 | }
136 | #endif
137 | #endif /* _FLUIDSYNTH_EVENT_H */
138 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/gen.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_GEN_H
22 | #define _FLUIDSYNTH_GEN_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /**
29 | * @file gen.h
30 | * @brief Functions and defines for SoundFont generator effects.
31 | */
32 |
33 | /**
34 | * Generator (effect) numbers (Soundfont 2.01 specifications section 8.1.3)
35 | */
36 | enum fluid_gen_type {
37 | GEN_STARTADDROFS, /**< Sample start address offset (0-32767) */
38 | GEN_ENDADDROFS, /**< Sample end address offset (-32767-0) */
39 | GEN_STARTLOOPADDROFS, /**< Sample loop start address offset (-32767-32767) */
40 | GEN_ENDLOOPADDROFS, /**< Sample loop end address offset (-32767-32767) */
41 | GEN_STARTADDRCOARSEOFS, /**< Sample start address coarse offset (X 32768) */
42 | GEN_MODLFOTOPITCH, /**< Modulation LFO to pitch */
43 | GEN_VIBLFOTOPITCH, /**< Vibrato LFO to pitch */
44 | GEN_MODENVTOPITCH, /**< Modulation envelope to pitch */
45 | GEN_FILTERFC, /**< Filter cutoff */
46 | GEN_FILTERQ, /**< Filter Q */
47 | GEN_MODLFOTOFILTERFC, /**< Modulation LFO to filter cutoff */
48 | GEN_MODENVTOFILTERFC, /**< Modulation envelope to filter cutoff */
49 | GEN_ENDADDRCOARSEOFS, /**< Sample end address coarse offset (X 32768) */
50 | GEN_MODLFOTOVOL, /**< Modulation LFO to volume */
51 | GEN_UNUSED1, /**< Unused */
52 | GEN_CHORUSSEND, /**< Chorus send amount */
53 | GEN_REVERBSEND, /**< Reverb send amount */
54 | GEN_PAN, /**< Stereo panning */
55 | GEN_UNUSED2, /**< Unused */
56 | GEN_UNUSED3, /**< Unused */
57 | GEN_UNUSED4, /**< Unused */
58 | GEN_MODLFODELAY, /**< Modulation LFO delay */
59 | GEN_MODLFOFREQ, /**< Modulation LFO frequency */
60 | GEN_VIBLFODELAY, /**< Vibrato LFO delay */
61 | GEN_VIBLFOFREQ, /**< Vibrato LFO frequency */
62 | GEN_MODENVDELAY, /**< Modulation envelope delay */
63 | GEN_MODENVATTACK, /**< Modulation envelope attack */
64 | GEN_MODENVHOLD, /**< Modulation envelope hold */
65 | GEN_MODENVDECAY, /**< Modulation envelope decay */
66 | GEN_MODENVSUSTAIN, /**< Modulation envelope sustain */
67 | GEN_MODENVRELEASE, /**< Modulation envelope release */
68 | GEN_KEYTOMODENVHOLD, /**< Key to modulation envelope hold */
69 | GEN_KEYTOMODENVDECAY, /**< Key to modulation envelope decay */
70 | GEN_VOLENVDELAY, /**< Volume envelope delay */
71 | GEN_VOLENVATTACK, /**< Volume envelope attack */
72 | GEN_VOLENVHOLD, /**< Volume envelope hold */
73 | GEN_VOLENVDECAY, /**< Volume envelope decay */
74 | GEN_VOLENVSUSTAIN, /**< Volume envelope sustain */
75 | GEN_VOLENVRELEASE, /**< Volume envelope release */
76 | GEN_KEYTOVOLENVHOLD, /**< Key to volume envelope hold */
77 | GEN_KEYTOVOLENVDECAY, /**< Key to volume envelope decay */
78 | GEN_INSTRUMENT, /**< Instrument ID (shouldn't be set by user) */
79 | GEN_RESERVED1, /**< Reserved */
80 | GEN_KEYRANGE, /**< MIDI note range */
81 | GEN_VELRANGE, /**< MIDI velocity range */
82 | GEN_STARTLOOPADDRCOARSEOFS, /**< Sample start loop address coarse offset (X 32768) */
83 | GEN_KEYNUM, /**< Fixed MIDI note number */
84 | GEN_VELOCITY, /**< Fixed MIDI velocity value */
85 | GEN_ATTENUATION, /**< Initial volume attenuation */
86 | GEN_RESERVED2, /**< Reserved */
87 | GEN_ENDLOOPADDRCOARSEOFS, /**< Sample end loop address coarse offset (X 32768) */
88 | GEN_COARSETUNE, /**< Coarse tuning */
89 | GEN_FINETUNE, /**< Fine tuning */
90 | GEN_SAMPLEID, /**< Sample ID (shouldn't be set by user) */
91 | GEN_SAMPLEMODE, /**< Sample mode flags */
92 | GEN_RESERVED3, /**< Reserved */
93 | GEN_SCALETUNE, /**< Scale tuning */
94 | GEN_EXCLUSIVECLASS, /**< Exclusive class number */
95 | GEN_OVERRIDEROOTKEY, /**< Sample root note override */
96 |
97 | /* the initial pitch is not a "standard" generator. It is not
98 | * mentioned in the list of generator in the SF2 specifications. It
99 | * is used, however, as the destination for the default pitch wheel
100 | * modulator. */
101 | GEN_PITCH, /**< Pitch @note Not a real SoundFont generator */
102 |
103 | GEN_CUSTOM_BALANCE, /**< Balance @note Not a real SoundFont generator */
104 | /* non-standard generator for an additional custom high- or low-pass filter */
105 | GEN_CUSTOM_FILTERFC, /**< Custom filter cutoff frequency */
106 | GEN_CUSTOM_FILTERQ, /**< Custom filter Q */
107 |
108 | #ifndef __DOXYGEN__
109 | GEN_LAST /**< @internal Value defines the count of generators (#fluid_gen_type) @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */
110 | #endif
111 | };
112 |
113 |
114 | #ifdef __cplusplus
115 | }
116 | #endif
117 | #endif /* _FLUIDSYNTH_GEN_H */
118 |
119 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/ladspa.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_LADSPA_H
22 | #define _FLUIDSYNTH_LADSPA_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /**
29 | * @file ladspa.h
30 | * @brief Functions for manipulating the ladspa effects unit
31 | *
32 | * This header defines useful functions for programatically manipulating the ladspa
33 | * effects unit of the synth that can be retrieved via fluid_synth_get_ladspa_fx().
34 | *
35 | * Using any of those functions requires fluidsynth to be compiled with ladspa support.
36 | * Else all of those functions are useless dummies.
37 | */
38 |
39 | FLUIDSYNTH_API int fluid_ladspa_is_active(fluid_ladspa_fx_t *fx);
40 | FLUIDSYNTH_API int fluid_ladspa_activate(fluid_ladspa_fx_t *fx);
41 | FLUIDSYNTH_API int fluid_ladspa_deactivate(fluid_ladspa_fx_t *fx);
42 | FLUIDSYNTH_API int fluid_ladspa_reset(fluid_ladspa_fx_t *fx);
43 | FLUIDSYNTH_API int fluid_ladspa_check(fluid_ladspa_fx_t *fx, char *err, int err_size);
44 |
45 | FLUIDSYNTH_API int fluid_ladspa_host_port_exists(fluid_ladspa_fx_t *fx, const char *name);
46 |
47 | FLUIDSYNTH_API int fluid_ladspa_add_buffer(fluid_ladspa_fx_t *fx, const char *name);
48 | FLUIDSYNTH_API int fluid_ladspa_buffer_exists(fluid_ladspa_fx_t *fx, const char *name);
49 |
50 | FLUIDSYNTH_API int fluid_ladspa_add_effect(fluid_ladspa_fx_t *fx, const char *effect_name,
51 | const char *lib_name, const char *plugin_name);
52 | FLUIDSYNTH_API int fluid_ladspa_effect_can_mix(fluid_ladspa_fx_t *fx, const char *name);
53 | FLUIDSYNTH_API int fluid_ladspa_effect_set_mix(fluid_ladspa_fx_t *fx, const char *name, int mix, float gain);
54 | FLUIDSYNTH_API int fluid_ladspa_effect_port_exists(fluid_ladspa_fx_t *fx, const char *effect_name, const char *port_name);
55 | FLUIDSYNTH_API int fluid_ladspa_effect_set_control(fluid_ladspa_fx_t *fx, const char *effect_name,
56 | const char *port_name, float val);
57 | FLUIDSYNTH_API int fluid_ladspa_effect_link(fluid_ladspa_fx_t *fx, const char *effect_name,
58 | const char *port_name, const char *name);
59 |
60 | #ifdef __cplusplus
61 | }
62 | #endif
63 |
64 | #endif /* _FLUIDSYNTH_LADSPA_H */
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/log.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_LOG_H
22 | #define _FLUIDSYNTH_LOG_H
23 |
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 |
30 | /**
31 | * @file log.h
32 | * @brief Logging interface
33 | *
34 | * The default logging function of the fluidsynth prints its messages
35 | * to the stderr. The synthesizer uses five level of messages: #FLUID_PANIC,
36 | * #FLUID_ERR, #FLUID_WARN, #FLUID_INFO, and #FLUID_DBG.
37 | *
38 | * A client application can install a new log function to handle the
39 | * messages differently. In the following example, the application
40 | * sets a callback function to display #FLUID_PANIC messages in a dialog,
41 | * and ignores all other messages by setting the log function to
42 | * NULL:
43 | *
44 | * @code
45 | * fluid_set_log_function(FLUID_PANIC, show_dialog, (void*) root_window);
46 | * fluid_set_log_function(FLUID_ERR, NULL, NULL);
47 | * fluid_set_log_function(FLUID_WARN, NULL, NULL);
48 | * fluid_set_log_function(FLUID_DBG, NULL, NULL);
49 | * @endcode
50 | */
51 |
52 | /**
53 | * FluidSynth log levels.
54 | */
55 | enum fluid_log_level {
56 | FLUID_PANIC, /**< The synth can't function correctly any more */
57 | FLUID_ERR, /**< Serious error occurred */
58 | FLUID_WARN, /**< Warning */
59 | FLUID_INFO, /**< Verbose informational messages */
60 | FLUID_DBG, /**< Debugging messages */
61 | #ifndef __DOXYGEN__
62 | LAST_LOG_LEVEL /**< @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */
63 | #endif
64 | };
65 |
66 | /**
67 | * Log function handler callback type used by fluid_set_log_function().
68 | * @param level Log level (#fluid_log_level)
69 | * @param message Log message text
70 | * @param data User data pointer supplied to fluid_set_log_function().
71 | */
72 | typedef void (*fluid_log_function_t)(int level, char* message, void* data);
73 |
74 | FLUIDSYNTH_API
75 | fluid_log_function_t fluid_set_log_function(int level, fluid_log_function_t fun, void* data);
76 |
77 | FLUIDSYNTH_API void fluid_default_log_function(int level, char* message, void* data);
78 |
79 | FLUIDSYNTH_API int fluid_log(int level, const char *fmt, ...);
80 |
81 |
82 | #ifdef __cplusplus
83 | }
84 | #endif
85 |
86 | #endif /* _FLUIDSYNTH_LOG_H */
87 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/misc.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_MISC_H
22 | #define _FLUIDSYNTH_MISC_H
23 |
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 |
30 | /**
31 | * @file misc.h
32 | * @brief Miscellaneous utility functions and defines
33 | */
34 |
35 | /**
36 | * Value that indicates success, used by most libfluidsynth functions.
37 | * @since 1.1.0
38 | *
39 | * @note This was not publicly defined prior to libfluidsynth 1.1.0. When
40 | * writing code which should also be compatible with older versions, something
41 | * like the following can be used:
42 | *
43 | * @code
44 | * #include
45 | *
46 | * #ifndef FLUID_OK
47 | * #define FLUID_OK (0)
48 | * #define FLUID_FAILED (-1)
49 | * #endif
50 | * @endcode
51 | */
52 | #define FLUID_OK (0)
53 |
54 | /**
55 | * Value that indicates failure, used by most libfluidsynth functions.
56 | * @since 1.1.0
57 | *
58 | * @note See #FLUID_OK for more details.
59 | */
60 | #define FLUID_FAILED (-1)
61 |
62 |
63 | FLUIDSYNTH_API int fluid_is_soundfont (const char *filename);
64 | FLUIDSYNTH_API int fluid_is_midifile (const char *filename);
65 |
66 |
67 | #ifdef __cplusplus
68 | }
69 | #endif
70 |
71 | #endif /* _FLUIDSYNTH_MISC_H */
72 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/mod.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_MOD_H
22 | #define _FLUIDSYNTH_MOD_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /**
29 | * @file mod.h
30 | * @brief SoundFont modulator functions and constants.
31 | */
32 |
33 |
34 | /**
35 | * Flags defining the polarity, mapping function and type of a modulator source.
36 | * Compare with SoundFont 2.04 PDF section 8.2.
37 | *
38 | * Note: Bit values do not correspond to the SoundFont spec! Also note that
39 | * #FLUID_MOD_GC and #FLUID_MOD_CC are in the flags field instead of the source field.
40 | */
41 | enum fluid_mod_flags
42 | {
43 | FLUID_MOD_POSITIVE = 0, /**< Mapping function is positive */
44 | FLUID_MOD_NEGATIVE = 1, /**< Mapping function is negative */
45 | FLUID_MOD_UNIPOLAR = 0, /**< Mapping function is unipolar */
46 | FLUID_MOD_BIPOLAR = 2, /**< Mapping function is bipolar */
47 | FLUID_MOD_LINEAR = 0, /**< Linear mapping function */
48 | FLUID_MOD_CONCAVE = 4, /**< Concave mapping function */
49 | FLUID_MOD_CONVEX = 8, /**< Convex mapping function */
50 | FLUID_MOD_SWITCH = 12, /**< Switch (on/off) mapping function */
51 | FLUID_MOD_GC = 0, /**< General controller source type (#fluid_mod_src) */
52 | FLUID_MOD_CC = 16, /**< MIDI CC controller (source will be a MIDI CC number) */
53 |
54 | FLUID_MOD_SIN = 0x80, /**< Custom non-standard sinus mapping function */
55 | };
56 |
57 | /**
58 | * General controller (if #FLUID_MOD_GC in flags). This
59 | * corresponds to SoundFont 2.04 PDF section 8.2.1
60 | */
61 | enum fluid_mod_src
62 | {
63 | FLUID_MOD_NONE = 0, /**< No source controller */
64 | FLUID_MOD_VELOCITY = 2, /**< MIDI note-on velocity */
65 | FLUID_MOD_KEY = 3, /**< MIDI note-on note number */
66 | FLUID_MOD_KEYPRESSURE = 10, /**< MIDI key pressure */
67 | FLUID_MOD_CHANNELPRESSURE = 13, /**< MIDI channel pressure */
68 | FLUID_MOD_PITCHWHEEL = 14, /**< Pitch wheel */
69 | FLUID_MOD_PITCHWHEELSENS = 16 /**< Pitch wheel sensitivity */
70 | };
71 |
72 | FLUIDSYNTH_API fluid_mod_t* new_fluid_mod(void);
73 | FLUIDSYNTH_API void delete_fluid_mod(fluid_mod_t * mod);
74 | FLUIDSYNTH_API size_t fluid_mod_sizeof(void);
75 |
76 | FLUIDSYNTH_API void fluid_mod_set_source1(fluid_mod_t* mod, int src, int flags);
77 | FLUIDSYNTH_API void fluid_mod_set_source2(fluid_mod_t* mod, int src, int flags);
78 | FLUIDSYNTH_API void fluid_mod_set_dest(fluid_mod_t* mod, int dst);
79 | FLUIDSYNTH_API void fluid_mod_set_amount(fluid_mod_t* mod, double amount);
80 |
81 | FLUIDSYNTH_API int fluid_mod_get_source1(const fluid_mod_t* mod);
82 | FLUIDSYNTH_API int fluid_mod_get_flags1(const fluid_mod_t* mod);
83 | FLUIDSYNTH_API int fluid_mod_get_source2(const fluid_mod_t* mod);
84 | FLUIDSYNTH_API int fluid_mod_get_flags2(const fluid_mod_t* mod);
85 | FLUIDSYNTH_API int fluid_mod_get_dest(const fluid_mod_t* mod);
86 | FLUIDSYNTH_API double fluid_mod_get_amount(const fluid_mod_t* mod);
87 |
88 | FLUIDSYNTH_API int fluid_mod_test_identity(const fluid_mod_t * mod1, const fluid_mod_t * mod2);
89 | FLUIDSYNTH_API int fluid_mod_has_source(const fluid_mod_t * mod, int cc, int ctrl);
90 | FLUIDSYNTH_API int fluid_mod_has_dest(const fluid_mod_t * mod, int gen);
91 |
92 | FLUIDSYNTH_API void fluid_mod_clone(fluid_mod_t* mod, const fluid_mod_t* src);
93 |
94 | #ifdef __cplusplus
95 | }
96 | #endif
97 | #endif /* _FLUIDSYNTH_MOD_H */
98 |
99 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/ramsfont.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | /* RAM SoundFonts: October 2002 - Antoine Schmitt */
22 |
23 | #ifndef _FLUIDSYNTH_RAMSFONT_H
24 | #define _FLUIDSYNTH_RAMSFONT_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /**
31 | * @file ramsfont.h
32 | * @brief API for creating and managing SoundFont instruments in RAM.
33 | *
34 | * RAM SoundFonts live in ram. The samples are loaded from files
35 | * or from RAM. A minimal API manages a soundFont structure,
36 | * with presets, each preset having only one preset-zone, which
37 | * instrument has potentially many instrument-zones. No global
38 | * zones, and nor generator nor modulator other than the default
39 | * ones are permitted. This may be extensible in the future.
40 | */
41 |
42 | FLUIDSYNTH_API fluid_sfont_t* fluid_ramsfont_create_sfont(void);
43 | FLUIDSYNTH_API int fluid_ramsfont_set_name(fluid_ramsfont_t* sfont, const char *name);
44 | FLUIDSYNTH_API
45 | int fluid_ramsfont_add_izone(fluid_ramsfont_t* sfont,
46 | unsigned int bank, unsigned int num, fluid_sample_t* sample,
47 | int lokey, int hikey);
48 | FLUIDSYNTH_API
49 | int fluid_ramsfont_remove_izone(fluid_ramsfont_t* sfont,
50 | unsigned int bank, unsigned int num, fluid_sample_t* sample);
51 | FLUIDSYNTH_API
52 | int fluid_ramsfont_izone_set_gen(fluid_ramsfont_t* sfont,
53 | unsigned int bank, unsigned int num, fluid_sample_t* sample,
54 | int gen_type, float value);
55 | FLUIDSYNTH_API
56 | int fluid_ramsfont_izone_set_loop(fluid_ramsfont_t* sfont,
57 | unsigned int bank, unsigned int num, fluid_sample_t* sample,
58 | int on, float loopstart, float loopend);
59 |
60 |
61 |
62 | #ifdef __cplusplus
63 | }
64 | #endif
65 |
66 | #endif /* _FLUIDSYNTH_RAMSFONT_H */
67 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/seq.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_SEQ_H
22 | #define _FLUIDSYNTH_SEQ_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /**
29 | * @file seq.h
30 | * @brief MIDI event sequencer.
31 | */
32 |
33 | /**
34 | * Event callback prototype for destination clients.
35 | * @param time Current sequencer tick value (see fluid_sequencer_get_tick()).
36 | * @param event The event being received
37 | * @param seq The sequencer instance
38 | * @param data User defined data registered with the client
39 | */
40 | typedef void (*fluid_event_callback_t)(unsigned int time, fluid_event_t* event,
41 | fluid_sequencer_t* seq, void* data);
42 |
43 |
44 | FLUIDSYNTH_API fluid_sequencer_t* new_fluid_sequencer(void);
45 | FLUIDSYNTH_API fluid_sequencer_t* new_fluid_sequencer2(int use_system_timer);
46 | FLUIDSYNTH_API void delete_fluid_sequencer(fluid_sequencer_t* seq);
47 | FLUIDSYNTH_API int fluid_sequencer_get_use_system_timer(fluid_sequencer_t* seq);
48 | FLUIDSYNTH_API
49 | fluid_seq_id_t fluid_sequencer_register_client(fluid_sequencer_t* seq, const char *name,
50 | fluid_event_callback_t callback, void* data);
51 | FLUIDSYNTH_API void fluid_sequencer_unregister_client(fluid_sequencer_t* seq, fluid_seq_id_t id);
52 | FLUIDSYNTH_API int fluid_sequencer_count_clients(fluid_sequencer_t* seq);
53 | FLUIDSYNTH_API fluid_seq_id_t fluid_sequencer_get_client_id(fluid_sequencer_t* seq, int index);
54 | FLUIDSYNTH_API char* fluid_sequencer_get_client_name(fluid_sequencer_t* seq, fluid_seq_id_t id);
55 | FLUIDSYNTH_API int fluid_sequencer_client_is_dest(fluid_sequencer_t* seq, fluid_seq_id_t id);
56 | FLUIDSYNTH_API void fluid_sequencer_process(fluid_sequencer_t* seq, unsigned int msec);
57 | FLUIDSYNTH_API void fluid_sequencer_send_now(fluid_sequencer_t* seq, fluid_event_t* evt);
58 | FLUIDSYNTH_API
59 | int fluid_sequencer_send_at(fluid_sequencer_t* seq, fluid_event_t* evt,
60 | unsigned int time, int absolute);
61 | FLUIDSYNTH_API
62 | void fluid_sequencer_remove_events(fluid_sequencer_t* seq, fluid_seq_id_t source, fluid_seq_id_t dest, int type);
63 | FLUIDSYNTH_API unsigned int fluid_sequencer_get_tick(fluid_sequencer_t* seq);
64 | FLUIDSYNTH_API void fluid_sequencer_set_time_scale(fluid_sequencer_t* seq, double scale);
65 | FLUIDSYNTH_API double fluid_sequencer_get_time_scale(fluid_sequencer_t* seq);
66 |
67 | // Compile in internal traceing functions
68 | #define FLUID_SEQ_WITH_TRACE 0
69 |
70 | #if FLUID_SEQ_WITH_TRACE
71 | FLUIDSYNTH_API char * fluid_seq_gettrace(fluid_sequencer_t* seq);
72 | FLUIDSYNTH_API void fluid_seq_cleartrace(fluid_sequencer_t* seq);
73 | #endif
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #endif /* _FLUIDSYNTH_SEQ_H */
80 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/seqbind.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_SEQBIND_H
22 | #define _FLUIDSYNTH_SEQBIND_H
23 |
24 | #include "seq.h"
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /**
31 | * @file seqbind.h
32 | * @brief Functions for binding sequencer objects to other subsystems.
33 | */
34 |
35 | FLUIDSYNTH_API
36 | fluid_seq_id_t fluid_sequencer_register_fluidsynth(fluid_sequencer_t* seq, fluid_synth_t* synth);
37 | FLUIDSYNTH_API int
38 | fluid_sequencer_add_midi_event_to_buffer(void* data, fluid_midi_event_t* event);
39 |
40 |
41 | #ifdef __cplusplus
42 | }
43 | #endif
44 | #endif /* _FLUIDSYNTH_SEQBIND_H */
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/shell.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_SHELL_H
22 | #define _FLUIDSYNTH_SHELL_H
23 |
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 |
30 | /**
31 | * @file shell.h
32 | * @brief Command shell interface
33 | *
34 | * The shell interface allows you to send simple textual commands to
35 | * the synthesizer, to parse a command file, or to read commands
36 | * from the stdin or other input streams.
37 | */
38 |
39 | FLUIDSYNTH_API fluid_istream_t fluid_get_stdin(void);
40 | FLUIDSYNTH_API fluid_ostream_t fluid_get_stdout(void);
41 |
42 | FLUIDSYNTH_API char* fluid_get_userconf(char* buf, int len);
43 | FLUIDSYNTH_API char* fluid_get_sysconf(char* buf, int len);
44 |
45 |
46 | /* The command handler */
47 |
48 | FLUIDSYNTH_API
49 | fluid_cmd_handler_t* new_fluid_cmd_handler(fluid_synth_t* synth, fluid_midi_router_t* router);
50 |
51 | FLUIDSYNTH_API
52 | void delete_fluid_cmd_handler(fluid_cmd_handler_t* handler);
53 |
54 | FLUIDSYNTH_API
55 | void fluid_cmd_handler_set_synth(fluid_cmd_handler_t* handler, fluid_synth_t* synth);
56 |
57 |
58 |
59 | /* Command function */
60 |
61 | FLUIDSYNTH_API
62 | int fluid_command(fluid_cmd_handler_t* handler, const char *cmd, fluid_ostream_t out);
63 |
64 | FLUIDSYNTH_API
65 | int fluid_source(fluid_cmd_handler_t* handler, const char *filename);
66 |
67 | FLUIDSYNTH_API
68 | void fluid_usershell(fluid_settings_t* settings, fluid_cmd_handler_t* handler);
69 |
70 |
71 | /* Shell */
72 |
73 | FLUIDSYNTH_API
74 | fluid_shell_t* new_fluid_shell(fluid_settings_t* settings, fluid_cmd_handler_t* handler,
75 | fluid_istream_t in, fluid_ostream_t out, int thread);
76 |
77 | FLUIDSYNTH_API void delete_fluid_shell(fluid_shell_t* shell);
78 |
79 |
80 |
81 | /* TCP/IP server */
82 |
83 |
84 | FLUIDSYNTH_API
85 | fluid_server_t* new_fluid_server(fluid_settings_t* settings,
86 | fluid_synth_t* synth, fluid_midi_router_t* router);
87 |
88 | FLUIDSYNTH_API void delete_fluid_server(fluid_server_t* server);
89 |
90 | FLUIDSYNTH_API int fluid_server_join(fluid_server_t* server);
91 |
92 |
93 | #ifdef __cplusplus
94 | }
95 | #endif
96 |
97 | #endif /* _FLUIDSYNTH_SHELL_H */
98 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/types.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_TYPES_H
22 | #define _FLUIDSYNTH_TYPES_H
23 |
24 |
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 |
31 | /**
32 | * @file types.h
33 | * @brief Type declarations
34 | */
35 |
36 | typedef struct _fluid_hashtable_t fluid_settings_t; /**< Configuration settings instance */
37 | typedef struct _fluid_synth_t fluid_synth_t; /**< Synthesizer instance */
38 | typedef struct _fluid_voice_t fluid_voice_t; /**< Synthesis voice instance */
39 | typedef struct _fluid_sfloader_t fluid_sfloader_t; /**< SoundFont loader plugin */
40 | typedef struct _fluid_sfont_t fluid_sfont_t; /**< SoundFont */
41 | typedef struct _fluid_preset_t fluid_preset_t; /**< SoundFont preset */
42 | typedef struct _fluid_sample_t fluid_sample_t; /**< SoundFont sample */
43 | typedef struct _fluid_mod_t fluid_mod_t; /**< SoundFont modulator */
44 | typedef struct _fluid_audio_driver_t fluid_audio_driver_t; /**< Audio driver instance */
45 | typedef struct _fluid_file_renderer_t fluid_file_renderer_t; /**< Audio file renderer instance */
46 | typedef struct _fluid_player_t fluid_player_t; /**< MIDI player instance */
47 | typedef struct _fluid_midi_event_t fluid_midi_event_t; /**< MIDI event */
48 | typedef struct _fluid_midi_driver_t fluid_midi_driver_t; /**< MIDI driver instance */
49 | typedef struct _fluid_midi_router_t fluid_midi_router_t; /**< MIDI router instance */
50 | typedef struct _fluid_midi_router_rule_t fluid_midi_router_rule_t; /**< MIDI router rule */
51 | typedef struct _fluid_hashtable_t fluid_cmd_hash_t; /**< Command handler hash table */
52 | typedef struct _fluid_shell_t fluid_shell_t; /**< Command shell */
53 | typedef struct _fluid_server_t fluid_server_t; /**< TCP/IP shell server instance */
54 | typedef struct _fluid_event_t fluid_event_t; /**< Sequencer event */
55 | typedef struct _fluid_sequencer_t fluid_sequencer_t; /**< Sequencer instance */
56 | typedef struct _fluid_ramsfont_t fluid_ramsfont_t; /**< RAM SoundFont */
57 | typedef struct _fluid_rampreset_t fluid_rampreset_t; /**< RAM SoundFont preset */
58 | typedef struct _fluid_cmd_handler_t fluid_cmd_handler_t; /**< Shell Command Handler */
59 | typedef struct _fluid_ladspa_fx_t fluid_ladspa_fx_t; /**< LADSPA effects instance */
60 | typedef struct _fluid_file_callbacks_t fluid_file_callbacks_t; /**< Callback struct to perform custom file loading of soundfonts */
61 |
62 | typedef int fluid_istream_t; /**< Input stream descriptor */
63 | typedef int fluid_ostream_t; /**< Output stream descriptor */
64 |
65 | typedef short fluid_seq_id_t; /**< Unique client IDs used by the sequencer and #fluid_event_t, obtained by fluid_sequencer_register_client() and fluid_sequencer_register_fluidsynth() */
66 |
67 | #ifdef __cplusplus
68 | }
69 | #endif
70 |
71 | #endif /* _FLUIDSYNTH_TYPES_H */
72 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/version.h.in:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_VERSION_H
22 | #define _FLUIDSYNTH_VERSION_H
23 |
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /**
30 | * @file version.h
31 | * @brief Library version functions and defines
32 | */
33 |
34 | #define FLUIDSYNTH_VERSION @FLUIDSYNTH_VERSION@ /**< String constant of libfluidsynth version. */
35 | #define FLUIDSYNTH_VERSION_MAJOR @FLUIDSYNTH_VERSION_MAJOR@ /**< libfluidsynth major version integer constant. */
36 | #define FLUIDSYNTH_VERSION_MINOR @FLUIDSYNTH_VERSION_MINOR@ /**< libfluidsynth minor version integer constant. */
37 | #define FLUIDSYNTH_VERSION_MICRO @FLUIDSYNTH_VERSION_MICRO@ /**< libfluidsynth micro version integer constant. */
38 |
39 | FLUIDSYNTH_API void fluid_version(int *major, int *minor, int *micro);
40 | FLUIDSYNTH_API char* fluid_version_str(void);
41 |
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 |
47 | #endif /* _FLUIDSYNTH_VERSION_H */
48 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/include/fluidsynth/voice.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUIDSYNTH_VOICE_H
22 | #define _FLUIDSYNTH_VOICE_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /**
29 | * @file voice.h
30 | * @brief Synthesis voice manipulation functions.
31 | *
32 | * The interface to the synthesizer's voices.
33 | * Examples on using them can be found in fluid_defsfont.c.
34 | * Most of these functions should only be called from within synthesis context,
35 | * such as the SoundFont loader's noteon method.
36 | */
37 |
38 |
39 | /**
40 | * Enum used with fluid_voice_add_mod() to specify how to handle duplicate modulators.
41 | */
42 | enum fluid_voice_add_mod {
43 | FLUID_VOICE_OVERWRITE, /**< Overwrite any existing matching modulator */
44 | FLUID_VOICE_ADD, /**< Add (sum) modulator amounts */
45 | FLUID_VOICE_DEFAULT /**< For default modulators only, no need to check for duplicates */
46 | };
47 |
48 | FLUIDSYNTH_API void fluid_voice_add_mod(fluid_voice_t* voice, fluid_mod_t* mod, int mode);
49 | FLUIDSYNTH_API float fluid_voice_gen_get(fluid_voice_t* voice, int gen);
50 | FLUIDSYNTH_API void fluid_voice_gen_set(fluid_voice_t* voice, int gen, float val);
51 | FLUIDSYNTH_API void fluid_voice_gen_incr(fluid_voice_t* voice, int gen, float val);
52 |
53 | FLUIDSYNTH_API unsigned int fluid_voice_get_id(const fluid_voice_t* voice);
54 | FLUIDSYNTH_API int fluid_voice_get_channel(const fluid_voice_t* voice);
55 | FLUIDSYNTH_API int fluid_voice_get_key(const fluid_voice_t* voice);
56 | FLUIDSYNTH_API int fluid_voice_get_actual_key(const fluid_voice_t* voice);
57 | FLUIDSYNTH_API int fluid_voice_get_velocity(const fluid_voice_t* voice);
58 | FLUIDSYNTH_API int fluid_voice_get_actual_velocity(const fluid_voice_t* voice);
59 | FLUIDSYNTH_API int fluid_voice_is_playing(const fluid_voice_t* voice);
60 | FLUIDSYNTH_API int fluid_voice_is_on(const fluid_voice_t* voice);
61 | FLUIDSYNTH_API int fluid_voice_is_sustained(const fluid_voice_t* voice);
62 | FLUIDSYNTH_API int fluid_voice_is_sostenuto(const fluid_voice_t* voice);
63 | FLUIDSYNTH_API int fluid_voice_optimize_sample(fluid_sample_t* s);
64 | FLUIDSYNTH_API void fluid_voice_update_param(fluid_voice_t* voice, int gen);
65 |
66 |
67 | #ifdef __cplusplus
68 | }
69 | #endif
70 | #endif /* _FLUIDSYNTH_VOICE_H */
71 |
72 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/bindings/fluid_ladspa.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUID_LADSPA_H
22 | #define _FLUID_LADSPA_H
23 |
24 | #include "fluid_sys.h"
25 |
26 | fluid_ladspa_fx_t *new_fluid_ladspa_fx(fluid_real_t sample_rate, int buffer_size);
27 | void delete_fluid_ladspa_fx(fluid_ladspa_fx_t *fx);
28 |
29 | int fluid_ladspa_set_sample_rate(fluid_ladspa_fx_t *fx, fluid_real_t sample_rate);
30 |
31 | void fluid_ladspa_run(fluid_ladspa_fx_t *fx, int block_count, int block_size);
32 |
33 | int fluid_ladspa_add_host_ports(fluid_ladspa_fx_t *fx, const char *prefix,
34 | int num_buffers, fluid_real_t *buffers[]);
35 |
36 | #endif /* _FLUID_LADSPA_H */
37 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/bindings/fluid_lash.c:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 | #include "fluid_lash.h"
21 | #include "fluid_synth.h"
22 |
23 | #include /* for usleep() */
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | static void fluid_lash_save (fluid_synth_t * synth);
31 | static void fluid_lash_load (fluid_synth_t * synth, const char * filename);
32 | static void *fluid_lash_run (void * data);
33 |
34 | /*
35 | * lash client - this symbol needs to be in the library else
36 | * all clients would need a fluid_lash_client symbol.
37 | */
38 | #ifdef HAVE_LASH
39 | lash_client_t * fluid_lash_client;
40 | #endif
41 |
42 | static pthread_t fluid_lash_thread;
43 |
44 |
45 | #ifdef HAVE_LASH
46 |
47 | fluid_lash_args_t *
48 | fluid_lash_extract_args (int * pargc, char *** pargv)
49 | {
50 | return lash_extract_args (pargc, pargv);
51 | }
52 |
53 | int
54 | fluid_lash_connect (fluid_lash_args_t * args)
55 | {
56 | fluid_lash_client = lash_init (args, PACKAGE, LASH_Config_Data_Set | LASH_Terminal, LASH_PROTOCOL (2,0));
57 | return fluid_lash_client && lash_enabled (fluid_lash_client);
58 | }
59 |
60 | void
61 | fluid_lash_create_thread (fluid_synth_t * synth)
62 | {
63 | pthread_create (&fluid_lash_thread, NULL, fluid_lash_run, synth);
64 | }
65 |
66 | static void
67 | fluid_lash_save (fluid_synth_t * synth)
68 | {
69 | int i;
70 | int sfcount;
71 | fluid_sfont_t * sfont;
72 | lash_config_t * config;
73 | char num[32];
74 |
75 | sfcount = fluid_synth_sfcount (synth);
76 |
77 | config = lash_config_new ();
78 | lash_config_set_key (config, "soundfont count");
79 | lash_config_set_value_int (config, sfcount);
80 | lash_send_config (fluid_lash_client, config);
81 |
82 | for (i = sfcount - 1; i >= 0; i--)
83 | {
84 | sfont = fluid_synth_get_sfont (synth, i);
85 | config = lash_config_new ();
86 |
87 | sprintf (num, "%d", i);
88 |
89 | lash_config_set_key (config, num);
90 | lash_config_set_value_string (config, sfont->get_name (sfont));
91 |
92 | lash_send_config (fluid_lash_client, config);
93 | }
94 | }
95 |
96 | static void
97 | fluid_lash_load (fluid_synth_t * synth, const char * filename)
98 | {
99 | fluid_synth_sfload (synth, filename, 1);
100 | }
101 |
102 | static void *
103 | fluid_lash_run (void * data)
104 | {
105 | lash_event_t * event;
106 | lash_config_t * config;
107 | fluid_synth_t * synth;
108 | int done = 0;
109 | int err;
110 | int pending_restores = 0;
111 |
112 | synth = (fluid_synth_t *) data;
113 |
114 | while (!done)
115 | {
116 | while ( (event = lash_get_event (fluid_lash_client)) )
117 | {
118 | switch (lash_event_get_type (event))
119 | {
120 | case LASH_Save_Data_Set:
121 | fluid_lash_save (synth);
122 | lash_send_event (fluid_lash_client, event);
123 | break;
124 | case LASH_Restore_Data_Set:
125 | lash_event_destroy (event);
126 | break;
127 | case LASH_Quit:
128 | err = kill (getpid(), SIGQUIT);
129 | if (err)
130 | fprintf (stderr, "%s: error sending signal: %s",
131 | __FUNCTION__, strerror (errno));
132 | lash_event_destroy (event);
133 | done = 1;
134 | break;
135 | case LASH_Server_Lost:
136 | lash_event_destroy (event);
137 | done = 1;
138 | break;
139 | default:
140 | fprintf (stderr, "Received unknown LASH event of type %d\n", lash_event_get_type (event));
141 | lash_event_destroy (event);
142 | break;
143 | }
144 | }
145 |
146 | while ( (config = lash_get_config (fluid_lash_client)) )
147 | {
148 | if (FLUID_STRCMP (lash_config_get_key (config), "soundfont count") == 0)
149 | pending_restores = lash_config_get_value_int (config);
150 | else
151 | {
152 | fluid_lash_load (synth, lash_config_get_value_string (config));
153 | pending_restores--;
154 | }
155 | lash_config_destroy (config);
156 |
157 | if (!pending_restores)
158 | {
159 | event = lash_event_new_with_type (LASH_Restore_Data_Set);
160 | lash_send_event (fluid_lash_client, event);
161 | }
162 | }
163 |
164 | usleep (10000);
165 | }
166 |
167 | return NULL;
168 | }
169 |
170 | #endif /* #if HAVE_LASH #else */
171 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/bindings/fluid_lash.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 | #include "config.h"
21 |
22 | #if defined(HAVE_LASH)
23 |
24 | #include "fluid_synth.h"
25 |
26 | #define LASH_ENABLED 1
27 |
28 | #ifdef HAVE_LASH
29 |
30 | #include
31 | extern lash_client_t * fluid_lash_client;
32 | #define fluid_lash_args_t lash_args_t
33 | #define fluid_lash_alsa_client_id lash_alsa_client_id
34 | #define fluid_lash_jack_client_name lash_jack_client_name
35 |
36 | #endif
37 |
38 |
39 | FLUIDSYNTH_API fluid_lash_args_t *fluid_lash_extract_args (int * pargc, char *** pargv);
40 | FLUIDSYNTH_API int fluid_lash_connect (fluid_lash_args_t * args);
41 | FLUIDSYNTH_API void fluid_lash_create_thread (fluid_synth_t * synth);
42 |
43 | #endif /* defined(HAVE_LASH) */
44 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/bindings/fluid_rtkit.h:
--------------------------------------------------------------------------------
1 | /*-*- Mode: C; c-basic-offset: 8 -*-*/
2 |
3 | #ifndef foortkithfoo
4 | #define foortkithfoo
5 |
6 | /***
7 | Copyright 2009 Lennart Poettering
8 | Copyright 2010 David Henningsson
9 |
10 | Permission is hereby granted, free of charge, to any person
11 | obtaining a copy of this software and associated documentation files
12 | (the "Software"), to deal in the Software without restriction,
13 | including without limitation the rights to use, copy, modify, merge,
14 | publish, distribute, sublicense, and/or sell copies of the Software,
15 | and to permit persons to whom the Software is furnished to do so,
16 | subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be
19 | included in all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 | SOFTWARE.
29 | ***/
30 |
31 | #ifdef DBUS_SUPPORT
32 |
33 | #include
34 | #include
35 |
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif
39 |
40 | /* This is the reference implementation for a client for
41 | * RealtimeKit. You don't have to use this, but if do, just copy these
42 | * sources into your repository */
43 |
44 | #define RTKIT_SERVICE_NAME "org.freedesktop.RealtimeKit1"
45 | #define RTKIT_OBJECT_PATH "/org/freedesktop/RealtimeKit1"
46 |
47 | /* This is mostly equivalent to sched_setparam(thread, SCHED_RR, {
48 | * .sched_priority = priority }). 'thread' needs to be a kernel thread
49 | * id as returned by gettid(), not a pthread_t! If 'thread' is 0 the
50 | * current thread is used. The returned value is a negative errno
51 | * style error code, or 0 on success. */
52 | int fluid_rtkit_make_realtime(pid_t thread, int priority);
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
57 |
58 | #endif
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/drivers/fluid_adriver.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUID_AUDRIVER_H
22 | #define _FLUID_AUDRIVER_H
23 |
24 | #include "fluid_sys.h"
25 |
26 | void fluid_audio_driver_settings(fluid_settings_t* settings);
27 |
28 |
29 | /*
30 | * fluid_audio_driver_t
31 | */
32 |
33 | struct _fluid_audio_driver_t
34 | {
35 | const char* name;
36 | };
37 |
38 |
39 | #endif /* _FLUID_AUDRIVER_H */
40 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/drivers/fluid_aufile.c:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | /* fluid_aufile.c
22 | *
23 | * Audio driver, outputs the audio to a file (non real-time)
24 | *
25 | */
26 |
27 | #include "fluid_sys.h"
28 | #include "fluid_adriver.h"
29 | #include "fluid_settings.h"
30 |
31 |
32 | /** fluid_file_audio_driver_t
33 | *
34 | * This structure should not be accessed directly. Use audio port
35 | * functions instead.
36 | */
37 | typedef struct {
38 | fluid_audio_driver_t driver;
39 | fluid_audio_func_t callback;
40 | void* data;
41 | fluid_file_renderer_t* renderer;
42 | int period_size;
43 | double sample_rate;
44 | fluid_timer_t* timer;
45 | unsigned int samples;
46 | } fluid_file_audio_driver_t;
47 |
48 |
49 | fluid_audio_driver_t* new_fluid_file_audio_driver(fluid_settings_t* settings,
50 | fluid_synth_t* synth);
51 |
52 | void delete_fluid_file_audio_driver(fluid_audio_driver_t* p);
53 | static int fluid_file_audio_run_s16(void* d, unsigned int msec);
54 |
55 | /**************************************************************
56 | *
57 | * 'file' audio driver
58 | *
59 | */
60 |
61 | fluid_audio_driver_t*
62 | new_fluid_file_audio_driver(fluid_settings_t* settings,
63 | fluid_synth_t* synth)
64 | {
65 | fluid_file_audio_driver_t* dev;
66 | int msec;
67 |
68 | dev = FLUID_NEW(fluid_file_audio_driver_t);
69 | if (dev == NULL) {
70 | FLUID_LOG(FLUID_ERR, "Out of memory");
71 | return NULL;
72 | }
73 | FLUID_MEMSET(dev, 0, sizeof(fluid_file_audio_driver_t));
74 |
75 | fluid_settings_getint(settings, "audio.period-size", &dev->period_size);
76 | fluid_settings_getnum(settings, "synth.sample-rate", &dev->sample_rate);
77 |
78 | dev->data = synth;
79 | dev->callback = (fluid_audio_func_t) fluid_synth_process;
80 | dev->samples = 0;
81 |
82 | dev->renderer = new_fluid_file_renderer(synth);
83 |
84 | if (dev->renderer == NULL)
85 | goto error_recovery;
86 |
87 | msec = (int) (0.5 + dev->period_size / dev->sample_rate * 1000.0);
88 | dev->timer = new_fluid_timer(msec, fluid_file_audio_run_s16, (void*) dev, TRUE, FALSE, TRUE);
89 | if (dev->timer == NULL) {
90 | FLUID_LOG(FLUID_PANIC, "Couldn't create the audio thread.");
91 | goto error_recovery;
92 | }
93 |
94 | return (fluid_audio_driver_t*) dev;
95 |
96 | error_recovery:
97 | delete_fluid_file_audio_driver((fluid_audio_driver_t*) dev);
98 | return NULL;
99 | }
100 |
101 | void delete_fluid_file_audio_driver(fluid_audio_driver_t* p)
102 | {
103 | fluid_file_audio_driver_t* dev = (fluid_file_audio_driver_t*) p;
104 | fluid_return_if_fail(dev != NULL);
105 |
106 | delete_fluid_timer(dev->timer);
107 | delete_fluid_file_renderer(dev->renderer);
108 |
109 | FLUID_FREE(dev);
110 | }
111 |
112 | static int fluid_file_audio_run_s16(void* d, unsigned int clock_time)
113 | {
114 | fluid_file_audio_driver_t* dev = (fluid_file_audio_driver_t*) d;
115 | unsigned int sample_time;
116 |
117 | sample_time = (unsigned int) (dev->samples / dev->sample_rate * 1000.0);
118 | if (sample_time > clock_time) {
119 | return 1;
120 | }
121 |
122 | dev->samples += dev->period_size;
123 |
124 | return fluid_file_renderer_process_block(dev->renderer) == FLUID_OK ? 1 : 0;
125 | }
126 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/drivers/fluid_coremidi.c:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | /* fluid_coremidi.c
22 | *
23 | * Driver for Mac OSX native MIDI
24 | * Pedro Lopez-Cabanillas, Jan 2009
25 | */
26 |
27 | #include "fluidsynth_priv.h"
28 |
29 | #if COREMIDI_SUPPORT
30 |
31 | #include "fluid_midi.h"
32 | #include "fluid_mdriver.h"
33 | #include "fluid_settings.h"
34 |
35 | /* Work around for OSX 10.4 */
36 |
37 | /* enum definition in OpenTransportProviders.h defines these tokens
38 | which are #defined from */
39 | #ifdef TCP_NODELAY
40 | #undef TCP_NODELAY
41 | #endif
42 | #ifdef TCP_MAXSEG
43 | #undef TCP_MAXSEG
44 | #endif
45 | #ifdef TCP_KEEPALIVE
46 | #undef TCP_KEEPALIVE
47 | #endif
48 |
49 | /* End work around */
50 |
51 | #include
52 | #include
53 | #include
54 |
55 | typedef struct {
56 | fluid_midi_driver_t driver;
57 | MIDIClientRef client;
58 | MIDIEndpointRef endpoint;
59 | fluid_midi_parser_t* parser;
60 | } fluid_coremidi_driver_t;
61 |
62 | fluid_midi_driver_t* new_fluid_coremidi_driver(fluid_settings_t* settings,
63 | handle_midi_event_func_t handler, void* data);
64 | void delete_fluid_coremidi_driver(fluid_midi_driver_t* p);
65 | void fluid_coremidi_callback(const MIDIPacketList *list, void *p, void *src);
66 |
67 | void fluid_coremidi_driver_settings(fluid_settings_t* settings)
68 | {
69 | fluid_settings_register_str(settings, "midi.coremidi.id", "pid", 0);
70 | }
71 |
72 | /*
73 | * new_fluid_coremidi_driver
74 | */
75 | fluid_midi_driver_t*
76 | new_fluid_coremidi_driver(fluid_settings_t* settings, handle_midi_event_func_t handler, void* data)
77 | {
78 | fluid_coremidi_driver_t* dev;
79 | MIDIClientRef client;
80 | MIDIEndpointRef endpoint;
81 | char clientid[32];
82 | char * portname;
83 | char * id;
84 | CFStringRef str_portname;
85 | CFStringRef str_clientname;
86 |
87 | /* not much use doing anything */
88 | if (handler == NULL) {
89 | FLUID_LOG(FLUID_ERR, "Invalid argument");
90 | return NULL;
91 | }
92 |
93 | dev = FLUID_MALLOC(sizeof(fluid_coremidi_driver_t));
94 | if (dev == NULL) {
95 | FLUID_LOG(FLUID_ERR, "Out of memory");
96 | return NULL;
97 | }
98 |
99 | dev->client = 0;
100 | dev->endpoint = 0;
101 | dev->parser = 0;
102 | dev->driver.handler = handler;
103 | dev->driver.data = data;
104 |
105 | dev->parser = new_fluid_midi_parser();
106 | if (dev->parser == NULL) {
107 | FLUID_LOG(FLUID_ERR, "Out of memory");
108 | goto error_recovery;
109 | }
110 |
111 | fluid_settings_dupstr(settings, "midi.coremidi.id", &id); /* ++ alloc id string */
112 | memset (clientid, 0, sizeof(clientid));
113 | if (id != NULL) {
114 | if (FLUID_STRCMP (id, "pid") == 0) {
115 | FLUID_SNPRINTF (clientid, sizeof(clientid), " (%d)", getpid());
116 | } else {
117 | FLUID_SNPRINTF (clientid, sizeof(clientid), " (%s)", id);
118 | }
119 | FLUID_FREE (id); /* -- free id string */
120 | }
121 | str_clientname = CFStringCreateWithFormat (NULL, NULL,
122 | CFSTR("FluidSynth%s"), clientid);
123 |
124 | fluid_settings_dupstr(settings, "midi.portname", &portname); /* ++ alloc port name */
125 | if (!portname || strlen(portname) == 0)
126 | str_portname = CFStringCreateWithFormat (NULL, NULL,
127 | CFSTR("FluidSynth virtual port%s"),
128 | clientid);
129 | else
130 | str_portname = CFStringCreateWithCString (NULL, portname,
131 | kCFStringEncodingASCII);
132 |
133 | if (portname) FLUID_FREE (portname); /* -- free port name */
134 |
135 | OSStatus result = MIDIClientCreate( str_clientname, NULL, NULL, &client );
136 | if ( result != noErr ) {
137 | FLUID_LOG(FLUID_ERR, "Failed to create the MIDI input client");
138 | goto error_recovery;
139 | }
140 | dev->client = client;
141 |
142 | result = MIDIDestinationCreate( client, str_portname,
143 | fluid_coremidi_callback,
144 | (void *)dev, &endpoint );
145 | if ( result != noErr ) {
146 | FLUID_LOG(FLUID_ERR, "Failed to create the MIDI input port. MIDI input not available.");
147 | goto error_recovery;
148 | }
149 | dev->endpoint = endpoint;
150 |
151 | return (fluid_midi_driver_t*) dev;
152 |
153 | error_recovery:
154 | delete_fluid_coremidi_driver((fluid_midi_driver_t*) dev);
155 | return NULL;
156 | }
157 |
158 | /*
159 | * delete_fluid_coremidi_driver
160 | */
161 | void
162 | delete_fluid_coremidi_driver(fluid_midi_driver_t* p)
163 | {
164 | fluid_coremidi_driver_t* dev = (fluid_coremidi_driver_t*) p;
165 | fluid_return_if_fail(dev != NULL);
166 |
167 | if (dev->client != NULL) {
168 | MIDIClientDispose(dev->client);
169 | }
170 | if (dev->endpoint != NULL) {
171 | MIDIEndpointDispose(dev->endpoint);
172 | }
173 | if (dev->parser != NULL) {
174 | delete_fluid_midi_parser(dev->parser);
175 | }
176 | FLUID_FREE(dev);
177 | }
178 |
179 | void
180 | fluid_coremidi_callback(const MIDIPacketList *list, void *p, void *src)
181 | {
182 | unsigned int i, j;
183 | fluid_midi_event_t* event;
184 | fluid_coremidi_driver_t* dev = (fluid_coremidi_driver_t *)p;
185 | const MIDIPacket *packet = &list->packet[0];
186 | for ( i = 0; i < list->numPackets; ++i ) {
187 | for ( j = 0; j < packet->length; ++j ) {
188 | event = fluid_midi_parser_parse(dev->parser, packet->data[j]);
189 | if (event != NULL) {
190 | (*dev->driver.handler)(dev->driver.data, event);
191 | }
192 | }
193 | packet = MIDIPacketNext(packet);
194 | }
195 | }
196 |
197 | #endif /* COREMIDI_SUPPORT */
198 |
199 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/drivers/fluid_mdriver.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUID_MDRIVER_H
22 | #define _FLUID_MDRIVER_H
23 |
24 | #include "fluid_sys.h"
25 |
26 | void fluid_midi_driver_settings(fluid_settings_t* settings);
27 |
28 |
29 | /*
30 | * fluid_midi_driver_t
31 | */
32 |
33 | struct _fluid_midi_driver_t
34 | {
35 | const char* name;
36 | handle_midi_event_func_t handler;
37 | void* data;
38 | };
39 |
40 |
41 |
42 | #endif /* _FLUID_AUDRIVER_H */
43 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/midi/fluid_midi_router.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | /* Author: Markus Nentwig, nentwig@users.sourceforge.net
22 | */
23 |
24 | #ifndef _FLUID_MIDIROUTER_H
25 | #define _FLUID_MIDIROUTER_H
26 |
27 | #include "fluidsynth_priv.h"
28 | #include "fluid_midi.h"
29 | #include "fluid_sys.h"
30 |
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/rvoice/fluid_adsr_env.c:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #include "fluid_adsr_env.h"
22 |
23 | void
24 | fluid_adsr_env_set_data(fluid_adsr_env_t* env,
25 | fluid_adsr_env_section_t section,
26 | unsigned int count,
27 | fluid_real_t coeff,
28 | fluid_real_t increment,
29 | fluid_real_t min,
30 | fluid_real_t max)
31 | {
32 | env->data[section].count = count;
33 | env->data[section].coeff = coeff;
34 | env->data[section].increment = increment;
35 | env->data[section].min = min;
36 | env->data[section].max = max;
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/rvoice/fluid_adsr_env.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUID_ADSR_ENVELOPE_H
22 | #define _FLUID_ADSR_ENVELOPE_H
23 |
24 | #include "fluidsynth_priv.h"
25 | #include "fluid_sys.h"
26 |
27 | /*
28 | * envelope data
29 | */
30 | struct _fluid_env_data_t {
31 | unsigned int count;
32 | fluid_real_t coeff;
33 | fluid_real_t increment;
34 | fluid_real_t min;
35 | fluid_real_t max;
36 | };
37 |
38 | /* Indices for envelope tables */
39 | enum fluid_voice_envelope_index_t{
40 | FLUID_VOICE_ENVDELAY,
41 | FLUID_VOICE_ENVATTACK,
42 | FLUID_VOICE_ENVHOLD,
43 | FLUID_VOICE_ENVDECAY,
44 | FLUID_VOICE_ENVSUSTAIN,
45 | FLUID_VOICE_ENVRELEASE,
46 | FLUID_VOICE_ENVFINISHED,
47 | FLUID_VOICE_ENVLAST
48 | };
49 |
50 | typedef enum fluid_voice_envelope_index_t fluid_adsr_env_section_t;
51 |
52 | typedef struct _fluid_adsr_env_t fluid_adsr_env_t;
53 |
54 | struct _fluid_adsr_env_t {
55 | fluid_env_data_t data[FLUID_VOICE_ENVLAST];
56 | unsigned int count;
57 | int section;
58 | fluid_real_t val; /* the current value of the envelope */
59 | };
60 |
61 | /* For performance, all functions are inlined */
62 |
63 | static FLUID_INLINE void
64 | fluid_adsr_env_calc(fluid_adsr_env_t* env, int is_volenv)
65 | {
66 | fluid_env_data_t* env_data;
67 | fluid_real_t x;
68 |
69 | env_data = &env->data[env->section];
70 |
71 | /* skip to the next section of the envelope if necessary */
72 | while (env->count >= env_data->count)
73 | {
74 | // If we're switching envelope stages from decay to sustain, force the value to be the end value of the previous stage
75 | // Hmm, should this only apply to volenv? It was so before refactoring, so keep it for now. [DH]
76 | if (env->section == FLUID_VOICE_ENVDECAY && is_volenv)
77 | env->val = env_data->min * env_data->coeff;
78 |
79 | env_data = &env->data[++env->section];
80 | env->count = 0;
81 | }
82 |
83 | /* calculate the envelope value and check for valid range */
84 | x = env_data->coeff * env->val + env_data->increment;
85 |
86 | if (x < env_data->min)
87 | {
88 | x = env_data->min;
89 | env->section++;
90 | env->count = 0;
91 | }
92 | else if (x > env_data->max)
93 | {
94 | x = env_data->max;
95 | env->section++;
96 | env->count = 0;
97 | }
98 | else env->count++;
99 |
100 | env->val = x;
101 |
102 |
103 | }
104 |
105 | /* This one cannot be inlined since it is referenced in
106 | the event queue */
107 | void
108 | fluid_adsr_env_set_data(fluid_adsr_env_t* env,
109 | fluid_adsr_env_section_t section,
110 | unsigned int count,
111 | fluid_real_t coeff,
112 | fluid_real_t increment,
113 | fluid_real_t min,
114 | fluid_real_t max);
115 |
116 | static FLUID_INLINE void
117 | fluid_adsr_env_reset(fluid_adsr_env_t* env)
118 | {
119 | env->count = 0;
120 | env->section = 0;
121 | env->val = 0.0f;
122 | }
123 |
124 | static FLUID_INLINE fluid_real_t
125 | fluid_adsr_env_get_val(fluid_adsr_env_t* env)
126 | {
127 | return env->val;
128 | }
129 |
130 | static FLUID_INLINE void
131 | fluid_adsr_env_set_val(fluid_adsr_env_t* env, fluid_real_t val)
132 | {
133 | env->val = val;
134 | }
135 |
136 | static FLUID_INLINE fluid_adsr_env_section_t
137 | fluid_adsr_env_get_section(fluid_adsr_env_t* env)
138 | {
139 | return env->section;
140 | }
141 |
142 | static FLUID_INLINE void
143 | fluid_adsr_env_set_section(fluid_adsr_env_t* env,
144 | fluid_adsr_env_section_t section)
145 | {
146 | env->section = section;
147 | env->count = 0;
148 | }
149 |
150 | /* Used for determining which voice to kill.
151 | Returns max amplitude from now, and forward in time.
152 | */
153 | static FLUID_INLINE fluid_real_t
154 | fluid_adsr_env_get_max_val(fluid_adsr_env_t* env)
155 | {
156 | if (env->section > FLUID_VOICE_ENVATTACK){
157 | return env->val * 1000;
158 | } else {
159 | return env->data[FLUID_VOICE_ENVATTACK].max;
160 | }
161 | }
162 |
163 | #endif
164 |
165 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/rvoice/fluid_chorus.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #ifndef _FLUID_CHORUS_H
23 | #define _FLUID_CHORUS_H
24 |
25 | #include "fluidsynth_priv.h"
26 |
27 |
28 | typedef struct _fluid_chorus_t fluid_chorus_t;
29 |
30 | /** Flags for fluid_chorus_set() */
31 | typedef enum
32 | {
33 | FLUID_CHORUS_SET_NR = 1 << 0,
34 | FLUID_CHORUS_SET_LEVEL = 1 << 1,
35 | FLUID_CHORUS_SET_SPEED = 1 << 2,
36 | FLUID_CHORUS_SET_DEPTH = 1 << 3,
37 | FLUID_CHORUS_SET_TYPE = 1 << 4,
38 |
39 | /** Value for fluid_chorus_set() which sets all chorus parameters. */
40 | FLUID_CHORUS_SET_ALL = FLUID_CHORUS_SET_NR
41 | | FLUID_CHORUS_SET_LEVEL
42 | | FLUID_CHORUS_SET_SPEED
43 | | FLUID_CHORUS_SET_DEPTH
44 | | FLUID_CHORUS_SET_TYPE,
45 | } fluid_chorus_set_t;
46 |
47 | /*
48 | * chorus
49 | */
50 | fluid_chorus_t* new_fluid_chorus(fluid_real_t sample_rate);
51 | void delete_fluid_chorus(fluid_chorus_t* chorus);
52 | int fluid_chorus_init(fluid_chorus_t* chorus);
53 | void fluid_chorus_reset(fluid_chorus_t* chorus);
54 |
55 | void fluid_chorus_set(fluid_chorus_t* chorus, int set, int nr, float level,
56 | float speed, float depth_ms, int type);
57 |
58 | void fluid_chorus_processmix(fluid_chorus_t* chorus, fluid_real_t *in,
59 | fluid_real_t *left_out, fluid_real_t *right_out);
60 | void fluid_chorus_processreplace(fluid_chorus_t* chorus, fluid_real_t *in,
61 | fluid_real_t *left_out, fluid_real_t *right_out);
62 |
63 |
64 |
65 | #endif /* _FLUID_CHORUS_H */
66 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/rvoice/fluid_iir_filter.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUID_IIR_FILTER_H
22 | #define _FLUID_IIR_FILTER_H
23 |
24 | #include "fluidsynth_priv.h"
25 |
26 | typedef struct _fluid_iir_filter_t fluid_iir_filter_t;
27 |
28 |
29 | void fluid_iir_filter_init(fluid_iir_filter_t* iir_filter, enum fluid_iir_filter_type, enum fluid_iir_filter_flags flags);
30 |
31 | void fluid_iir_filter_apply(fluid_iir_filter_t* iir_filter,
32 | fluid_real_t *dsp_buf, int dsp_buf_count);
33 |
34 | void fluid_iir_filter_reset(fluid_iir_filter_t* iir_filter);
35 |
36 | void fluid_iir_filter_set_q(fluid_iir_filter_t* iir_filter, fluid_real_t q);
37 |
38 | void fluid_iir_filter_set_fres(fluid_iir_filter_t* iir_filter,
39 | fluid_real_t fres);
40 |
41 | void fluid_iir_filter_calc(fluid_iir_filter_t* iir_filter,
42 | fluid_real_t output_rate,
43 | fluid_real_t fres_mod);
44 |
45 | /* We can't do information hiding here, as fluid_voice_t includes the struct
46 | without a pointer. */
47 | struct _fluid_iir_filter_t
48 | {
49 | enum fluid_iir_filter_type type; /* specifies the type of this filter */
50 | enum fluid_iir_filter_flags flags; /* additional flags to customize this filter */
51 |
52 | /* filter coefficients */
53 | /* The coefficients are normalized to a0. */
54 | /* b0 and b2 are identical => b02 */
55 | fluid_real_t b02; /* b0 / a0 */
56 | fluid_real_t b1; /* b1 / a0 */
57 | fluid_real_t a1; /* a0 / a0 */
58 | fluid_real_t a2; /* a1 / a0 */
59 |
60 | fluid_real_t b02_incr;
61 | fluid_real_t b1_incr;
62 | fluid_real_t a1_incr;
63 | fluid_real_t a2_incr;
64 | int filter_coeff_incr_count;
65 | int compensate_incr; /* Flag: If set, must compensate history */
66 | fluid_real_t hist1, hist2; /* Sample history for the IIR filter */
67 | int filter_startup; /* Flag: If set, the filter will be set directly.
68 | Else it changes smoothly. */
69 |
70 | fluid_real_t fres; /* the resonance frequency, in cents (not absolute cents) */
71 | fluid_real_t last_fres; /* Current resonance frequency of the IIR filter */
72 | /* Serves as a flag: A deviation between fres and last_fres */
73 | /* indicates, that the filter has to be recalculated. */
74 | fluid_real_t q_lin; /* the q-factor on a linear scale */
75 | fluid_real_t filter_gain; /* Gain correction factor, depends on q */
76 | };
77 |
78 | #endif
79 |
80 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/rvoice/fluid_lfo.c:
--------------------------------------------------------------------------------
1 | #include "fluid_lfo.h"
2 |
3 | void
4 | fluid_lfo_set_incr(fluid_lfo_t* lfo, fluid_real_t increment)
5 | {
6 | lfo->increment = increment;
7 | }
8 |
9 | void
10 | fluid_lfo_set_delay(fluid_lfo_t* lfo, unsigned int delay)
11 | {
12 | lfo->delay = delay;
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/rvoice/fluid_lfo.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUID_LFO_H
22 | #define _FLUID_LFO_H
23 |
24 | #include "fluid_sys.h"
25 |
26 | typedef struct _fluid_lfo_t fluid_lfo_t;
27 |
28 | struct _fluid_lfo_t {
29 | fluid_real_t val; /* the current value of the LFO */
30 | unsigned int delay; /* the delay of the lfo in samples */
31 | fluid_real_t increment; /* the lfo frequency is converted to a per-buffer increment */
32 | };
33 |
34 | static FLUID_INLINE void
35 | fluid_lfo_reset(fluid_lfo_t* lfo)
36 | {
37 | lfo->val = 0.0f;
38 | }
39 |
40 | // These two cannot be inlined since they're used by event_dispatch
41 | void fluid_lfo_set_incr(fluid_lfo_t* lfo, fluid_real_t increment);
42 | void fluid_lfo_set_delay(fluid_lfo_t* lfo, unsigned int delay);
43 |
44 | static FLUID_INLINE fluid_real_t
45 | fluid_lfo_get_val(fluid_lfo_t* lfo)
46 | {
47 | return lfo->val;
48 | }
49 |
50 | static FLUID_INLINE void
51 | fluid_lfo_calc(fluid_lfo_t* lfo, unsigned int cur_delay)
52 | {
53 | if (cur_delay < lfo->delay)
54 | return;
55 |
56 | lfo->val += lfo->increment;
57 |
58 | if (lfo->val > (fluid_real_t) 1.0)
59 | {
60 | lfo->increment = -lfo->increment;
61 | lfo->val = (fluid_real_t) 2.0 - lfo->val;
62 | }
63 | else if (lfo->val < (fluid_real_t) -1.0)
64 | {
65 | lfo->increment = -lfo->increment;
66 | lfo->val = (fluid_real_t) -2.0 - lfo->val;
67 | }
68 |
69 | }
70 |
71 | #endif
72 |
73 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/rvoice/fluid_phase.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #ifndef _FLUID_PHASE_H
23 | #define _FLUID_PHASE_H
24 |
25 | #include "config.h"
26 |
27 | /*
28 | * phase
29 | */
30 |
31 | #define FLUID_INTERP_BITS 8
32 | #define FLUID_INTERP_BITS_MASK 0xff000000
33 | #define FLUID_INTERP_BITS_SHIFT 24
34 | #define FLUID_INTERP_MAX 256
35 |
36 | #define FLUID_FRACT_MAX ((double)4294967296.0)
37 |
38 | /* fluid_phase_t
39 | * Purpose:
40 | * Playing pointer for voice playback
41 | *
42 | * When a sample is played back at a different pitch, the playing pointer in the
43 | * source sample will not advance exactly one sample per output sample.
44 | * This playing pointer is implemented using fluid_phase_t.
45 | * It is a 64 bit number. The higher 32 bits contain the 'index' (number of
46 | * the current sample), the lower 32 bits the fractional part.
47 | */
48 | typedef uint64_t fluid_phase_t;
49 |
50 | /* Purpose:
51 | * Set a to b.
52 | * a: fluid_phase_t
53 | * b: fluid_phase_t
54 | */
55 | #define fluid_phase_set(a,b) a=b;
56 |
57 | #define fluid_phase_set_int(a, b) ((a) = ((uint64_t)(b)) << 32)
58 |
59 | /* Purpose:
60 | * Sets the phase a to a phase increment given in b.
61 | * For example, assume b is 0.9. After setting a to it, adding a to
62 | * the playing pointer will advance it by 0.9 samples. */
63 | #define fluid_phase_set_float(a, b) \
64 | (a) = (((uint64_t)(b)) << 32) \
65 | | (uint32_t) (((double)(b) - (int)(b)) * (double)FLUID_FRACT_MAX)
66 |
67 | /* create a fluid_phase_t from an index and a fraction value */
68 | #define fluid_phase_from_index_fract(index, fract) \
69 | ((((uint64_t)(index)) << 32) + (fract))
70 |
71 | /* Purpose:
72 | * Return the index and the fractional part, respectively. */
73 | #define fluid_phase_index(_x) \
74 | ((unsigned int)((_x) >> 32))
75 | #define fluid_phase_fract(_x) \
76 | ((uint32_t)((_x) & 0xFFFFFFFF))
77 |
78 | /* Get the phase index with fractional rounding */
79 | #define fluid_phase_index_round(_x) \
80 | ((unsigned int)(((_x) + 0x80000000) >> 32))
81 |
82 |
83 | /* Purpose:
84 | * Takes the fractional part of the argument phase and
85 | * calculates the corresponding position in the interpolation table.
86 | * The fractional position of the playing pointer is calculated with a quite high
87 | * resolution (32 bits). It would be unpractical to keep a set of interpolation
88 | * coefficients for each possible fractional part...
89 | */
90 | #define fluid_phase_fract_to_tablerow(_x) \
91 | ((unsigned int)(fluid_phase_fract(_x) & FLUID_INTERP_BITS_MASK) >> FLUID_INTERP_BITS_SHIFT)
92 |
93 | #define fluid_phase_double(_x) \
94 | ((double)(fluid_phase_index(_x)) + ((double)fluid_phase_fract(_x) / FLUID_FRACT_MAX))
95 |
96 | /* Purpose:
97 | * Advance a by a step of b (both are fluid_phase_t).
98 | */
99 | #define fluid_phase_incr(a, b) a += b
100 |
101 | /* Purpose:
102 | * Subtract b from a (both are fluid_phase_t).
103 | */
104 | #define fluid_phase_decr(a, b) a -= b
105 |
106 | /* Purpose:
107 | * Subtract b samples from a.
108 | */
109 | #define fluid_phase_sub_int(a, b) ((a) -= (uint64_t)(b) << 32)
110 |
111 | /* Purpose:
112 | * Creates the expression a.index++. */
113 | #define fluid_phase_index_plusplus(a) (((a) += 0x100000000LL)
114 |
115 | #endif /* _FLUID_PHASE_H */
116 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/rvoice/fluid_rev.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #ifndef _FLUID_REV_H
23 | #define _FLUID_REV_H
24 |
25 | #include "fluidsynth_priv.h"
26 |
27 | typedef struct _fluid_revmodel_t fluid_revmodel_t;
28 |
29 |
30 | /** Flags for fluid_revmodel_set() */
31 | typedef enum
32 | {
33 | FLUID_REVMODEL_SET_ROOMSIZE = 1 << 0,
34 | FLUID_REVMODEL_SET_DAMPING = 1 << 1,
35 | FLUID_REVMODEL_SET_WIDTH = 1 << 2,
36 | FLUID_REVMODEL_SET_LEVEL = 1 << 3,
37 |
38 | /** Value for fluid_revmodel_set() which sets all reverb parameters. */
39 | FLUID_REVMODEL_SET_ALL = FLUID_REVMODEL_SET_LEVEL
40 | | FLUID_REVMODEL_SET_WIDTH
41 | | FLUID_REVMODEL_SET_DAMPING
42 | | FLUID_REVMODEL_SET_ROOMSIZE,
43 | } fluid_revmodel_set_t;
44 |
45 | /*
46 | * reverb preset
47 | */
48 | typedef struct _fluid_revmodel_presets_t {
49 | const char* name;
50 | fluid_real_t roomsize;
51 | fluid_real_t damp;
52 | fluid_real_t width;
53 | fluid_real_t level;
54 | } fluid_revmodel_presets_t;
55 |
56 |
57 | /*
58 | * reverb
59 | */
60 | fluid_revmodel_t* new_fluid_revmodel(fluid_real_t sample_rate);
61 | void delete_fluid_revmodel(fluid_revmodel_t* rev);
62 |
63 | void fluid_revmodel_processmix(fluid_revmodel_t* rev, fluid_real_t *in,
64 | fluid_real_t *left_out, fluid_real_t *right_out);
65 |
66 | void fluid_revmodel_processreplace(fluid_revmodel_t* rev, fluid_real_t *in,
67 | fluid_real_t *left_out, fluid_real_t *right_out);
68 |
69 | void fluid_revmodel_reset(fluid_revmodel_t* rev);
70 |
71 | void fluid_revmodel_set(fluid_revmodel_t* rev, int set, float roomsize,
72 | float damping, float width, float level);
73 |
74 | void fluid_revmodel_samplerate_change(fluid_revmodel_t* rev, fluid_real_t sample_rate);
75 |
76 | #endif /* _FLUID_REV_H */
77 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/rvoice/fluid_rvoice_event.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #ifndef _FLUID_RVOICE_EVENT_H
23 | #define _FLUID_RVOICE_EVENT_H
24 |
25 | #include "fluidsynth_priv.h"
26 | #include "fluid_rvoice_mixer.h"
27 | #include "fluid_ringbuffer.h"
28 |
29 | #define EVENT_REAL_PARAMS (5)
30 |
31 | typedef struct _fluid_rvoice_event_t fluid_rvoice_event_t;
32 | typedef struct _fluid_rvoice_eventhandler_t fluid_rvoice_eventhandler_t;
33 |
34 | struct _fluid_rvoice_event_t {
35 | void* method;
36 | void* object;
37 | void* ptr;
38 | int intparam;
39 | fluid_real_t realparams[EVENT_REAL_PARAMS];
40 | };
41 |
42 | void fluid_rvoice_event_dispatch(fluid_rvoice_event_t* event);
43 |
44 |
45 | /*
46 | * Bridge between the renderer thread and the midi state thread.
47 | * If is_threadsafe is true, that means fluid_rvoice_eventhandler_fetch_all
48 | * can be called in parallell with fluid_rvoice_eventhandler_push/flush
49 | */
50 | struct _fluid_rvoice_eventhandler_t {
51 | int is_threadsafe; /* False for optimal performance, true for atomic operations */
52 | fluid_ringbuffer_t* queue; /**< List of fluid_rvoice_event_t */
53 | fluid_atomic_int_t queue_stored; /**< Extras pushed but not flushed */
54 | fluid_ringbuffer_t* finished_voices; /**< return queue from handler, list of fluid_rvoice_t* */
55 | fluid_rvoice_mixer_t* mixer;
56 | };
57 |
58 | fluid_rvoice_eventhandler_t* new_fluid_rvoice_eventhandler(
59 | int is_threadsafe, int queuesize, int finished_voices_size, int bufs,
60 | int fx_bufs, fluid_real_t sample_rate);
61 |
62 | void delete_fluid_rvoice_eventhandler(fluid_rvoice_eventhandler_t*);
63 |
64 | int fluid_rvoice_eventhandler_dispatch_all(fluid_rvoice_eventhandler_t*);
65 | int fluid_rvoice_eventhandler_dispatch_count(fluid_rvoice_eventhandler_t*);
66 |
67 | static FLUID_INLINE void
68 | fluid_rvoice_eventhandler_flush(fluid_rvoice_eventhandler_t* handler)
69 | {
70 | int queue_stored = fluid_atomic_int_get(&handler->queue_stored);
71 |
72 | if (queue_stored > 0) {
73 | fluid_atomic_int_set(&handler->queue_stored, 0);
74 | fluid_ringbuffer_next_inptr(handler->queue, queue_stored);
75 | }
76 | }
77 |
78 | /**
79 | * @return next finished voice, or NULL if nothing in queue
80 | */
81 | static FLUID_INLINE fluid_rvoice_t*
82 | fluid_rvoice_eventhandler_get_finished_voice(fluid_rvoice_eventhandler_t* handler)
83 | {
84 | void* result = fluid_ringbuffer_get_outptr(handler->finished_voices);
85 | if (result == NULL) return NULL;
86 | result = * (fluid_rvoice_t**) result;
87 | fluid_ringbuffer_next_outptr(handler->finished_voices);
88 | return result;
89 | }
90 |
91 |
92 | int fluid_rvoice_eventhandler_push(fluid_rvoice_eventhandler_t* handler,
93 | void* method, void* object, int intparam,
94 | fluid_real_t realparam);
95 |
96 | int fluid_rvoice_eventhandler_push_ptr(fluid_rvoice_eventhandler_t* handler,
97 | void* method, void* object, void* ptr);
98 |
99 | int fluid_rvoice_eventhandler_push5(fluid_rvoice_eventhandler_t* handler,
100 | void* method, void* object, int intparam,
101 | fluid_real_t r1, fluid_real_t r2,
102 | fluid_real_t r3, fluid_real_t r4, fluid_real_t r5);
103 |
104 | static FLUID_INLINE void
105 | fluid_rvoice_eventhandler_add_rvoice(fluid_rvoice_eventhandler_t* handler,
106 | fluid_rvoice_t* rvoice)
107 | {
108 | if (handler->is_threadsafe)
109 | fluid_rvoice_eventhandler_push_ptr(handler, fluid_rvoice_mixer_add_voice,
110 | handler->mixer, rvoice);
111 | else
112 | fluid_rvoice_mixer_add_voice(handler->mixer, rvoice);
113 | }
114 |
115 |
116 |
117 | #endif
118 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/rvoice/fluid_rvoice_mixer.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #ifndef _FLUID_RVOICE_MIXER_H
23 | #define _FLUID_RVOICE_MIXER_H
24 |
25 | #include "fluidsynth_priv.h"
26 | #include "fluid_rvoice.h"
27 | #include "fluid_ladspa.h"
28 |
29 | typedef struct _fluid_rvoice_mixer_t fluid_rvoice_mixer_t;
30 |
31 | #define FLUID_MIXER_MAX_BUFFERS_DEFAULT (8192/FLUID_BUFSIZE)
32 |
33 |
34 | void fluid_rvoice_mixer_set_finished_voices_callback(
35 | fluid_rvoice_mixer_t* mixer,
36 | void (*func)(void*, fluid_rvoice_t*),
37 | void* userdata);
38 |
39 |
40 | int fluid_rvoice_mixer_render(fluid_rvoice_mixer_t* mixer, int blockcount);
41 | int fluid_rvoice_mixer_get_bufs(fluid_rvoice_mixer_t* mixer,
42 | fluid_real_t*** left, fluid_real_t*** right);
43 | int fluid_rvoice_mixer_get_fx_bufs(fluid_rvoice_mixer_t* mixer,
44 | fluid_real_t*** fx_left, fluid_real_t*** fx_right);
45 | int fluid_rvoice_mixer_get_bufcount(fluid_rvoice_mixer_t* mixer);
46 |
47 | fluid_rvoice_mixer_t* new_fluid_rvoice_mixer(int buf_count, int fx_buf_count,
48 | fluid_real_t sample_rate);
49 |
50 | void delete_fluid_rvoice_mixer(fluid_rvoice_mixer_t*);
51 |
52 | void fluid_rvoice_mixer_set_samplerate(fluid_rvoice_mixer_t* mixer, fluid_real_t samplerate);
53 | void fluid_rvoice_mixer_set_reverb_enabled(fluid_rvoice_mixer_t* mixer, int on);
54 | void fluid_rvoice_mixer_set_chorus_enabled(fluid_rvoice_mixer_t* mixer, int on);
55 | void fluid_rvoice_mixer_set_mix_fx(fluid_rvoice_mixer_t* mixer, int on);
56 | int fluid_rvoice_mixer_set_polyphony(fluid_rvoice_mixer_t* handler, int value);
57 | int fluid_rvoice_mixer_add_voice(fluid_rvoice_mixer_t* mixer, fluid_rvoice_t* voice);
58 | void fluid_rvoice_mixer_set_chorus_params(fluid_rvoice_mixer_t* mixer, int set,
59 | int nr, double level, double speed,
60 | double depth_ms, int type);
61 | void fluid_rvoice_mixer_set_reverb_params(fluid_rvoice_mixer_t* mixer, int set,
62 | double roomsize, double damping,
63 | double width, double level);
64 | void fluid_rvoice_mixer_reset_fx(fluid_rvoice_mixer_t* mixer);
65 | void fluid_rvoice_mixer_reset_reverb(fluid_rvoice_mixer_t* mixer);
66 | void fluid_rvoice_mixer_reset_chorus(fluid_rvoice_mixer_t* mixer);
67 |
68 | void fluid_rvoice_mixer_set_threads(fluid_rvoice_mixer_t* mixer, int thread_count,
69 | int prio_level);
70 |
71 | #ifdef LADSPA
72 | void fluid_rvoice_mixer_set_ladspa(fluid_rvoice_mixer_t* mixer,
73 | fluid_ladspa_fx_t *ladspa_fx, int audio_groups);
74 | #endif
75 |
76 | #endif
77 |
78 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/sfloader/fluid_ramsfont.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #ifndef _FLUID_RAMSFONT_H
23 | #define _FLUID_RAMSFONT_H
24 |
25 |
26 | #include "fluidsynth.h"
27 | #include "fluidsynth_priv.h"
28 |
29 | #include "fluid_sfont.h"
30 | #include "fluid_defsfont.h"
31 |
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 |
38 | /*
39 | * fluid_ramsfont_t
40 | */
41 | struct _fluid_ramsfont_t
42 | {
43 | char name[21]; /* the name of the soundfont */
44 | fluid_list_t* sample; /* the samples in this soundfont */
45 | fluid_rampreset_t* preset; /* the presets of this soundfont */
46 |
47 | fluid_preset_t iter_preset; /* preset interface used in the iteration */
48 | fluid_rampreset_t* iter_cur; /* the current preset in the iteration */
49 | };
50 |
51 | /*
52 | * fluid_preset_t
53 | */
54 | struct _fluid_rampreset_t
55 | {
56 | fluid_rampreset_t* next;
57 | fluid_ramsfont_t* sfont; /* the soundfont this preset belongs to */
58 | char name[21]; /* the name of the preset */
59 | unsigned int bank; /* the bank number */
60 | unsigned int num; /* the preset number */
61 | fluid_preset_zone_t* global_zone; /* the global zone of the preset */
62 | fluid_preset_zone_t* zone; /* the chained list of preset zones */
63 | fluid_list_t *presetvoices; /* chained list of used voices */
64 | };
65 |
66 |
67 | #ifdef __cplusplus
68 | }
69 | #endif
70 |
71 | #endif /* _FLUID_SFONT_H */
72 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/synth/fluid_event_priv.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #ifndef _FLUID_EVENT_PRIV_H
23 | #define _FLUID_EVENT_PRIV_H
24 |
25 | #include "fluidsynth.h"
26 | #include "fluid_sys.h"
27 |
28 | /* Private data for event */
29 | /* ?? should be optimized in size, using unions */
30 | struct _fluid_event_t {
31 | unsigned int time;
32 | int type;
33 | fluid_seq_id_t src;
34 | fluid_seq_id_t dest;
35 | int channel;
36 | short key;
37 | short vel;
38 | short control;
39 | short value;
40 | short id; //?? unused ?
41 | int pitch;
42 | unsigned int duration;
43 | void* data;
44 | };
45 |
46 | unsigned int fluid_event_get_time(fluid_event_t* evt);
47 | void fluid_event_set_time(fluid_event_t* evt, unsigned int time);
48 |
49 | void fluid_event_clear(fluid_event_t* evt);
50 |
51 | /* private data for sorter + heap */
52 | enum fluid_evt_entry_type {
53 | FLUID_EVT_ENTRY_INSERT = 0,
54 | FLUID_EVT_ENTRY_REMOVE
55 | };
56 |
57 | typedef struct _fluid_evt_entry fluid_evt_entry;
58 | struct _fluid_evt_entry {
59 | fluid_evt_entry *next;
60 | short entryType;
61 | fluid_event_t evt;
62 | };
63 |
64 | #define HEAP_WITH_DYNALLOC 1
65 | /* #undef HEAP_WITH_DYNALLOC */
66 |
67 | typedef struct _fluid_evt_heap_t {
68 | #ifdef HEAP_WITH_DYNALLOC
69 | fluid_evt_entry* freelist;
70 | fluid_mutex_t mutex;
71 | #else
72 | fluid_evt_entry* head;
73 | fluid_evt_entry* tail;
74 | fluid_evt_entry pool;
75 | #endif
76 | } fluid_evt_heap_t;
77 |
78 | fluid_evt_heap_t* _fluid_evt_heap_init(int nbEvents);
79 | void _fluid_evt_heap_free(fluid_evt_heap_t* heap);
80 | fluid_evt_entry* _fluid_seq_heap_get_free(fluid_evt_heap_t* heap);
81 | void _fluid_seq_heap_set_free(fluid_evt_heap_t* heap, fluid_evt_entry* evt);
82 |
83 | #endif /* _FLUID_EVENT_PRIV_H */
84 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/synth/fluid_gen.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #ifndef _FLUID_GEN_H
23 | #define _FLUID_GEN_H
24 |
25 | #include "fluidsynth_priv.h"
26 |
27 | typedef struct _fluid_gen_info_t {
28 | char num; /* Generator number */
29 | char init; /* Does the generator need to be initialized (cfr. fluid_voice_init()) */
30 | char nrpn_scale; /* The scale to convert from NRPN (cfr. fluid_gen_map_nrpn()) */
31 | float min; /* The minimum value */
32 | float max; /* The maximum value */
33 | float def; /* The default value (cfr. fluid_gen_set_default_values()) */
34 | } fluid_gen_info_t;
35 |
36 | /*
37 | * SoundFont generator structure.
38 | */
39 | typedef struct _fluid_gen_t
40 | {
41 | unsigned char flags; /**< Is the generator set or not (#fluid_gen_flags) */
42 | double val; /**< The nominal value */
43 | double mod; /**< Change by modulators */
44 | double nrpn; /**< Change by NRPN messages */
45 | } fluid_gen_t;
46 |
47 | /*
48 | * Enum value for 'flags' field of #fluid_gen_t (not really flags).
49 | */
50 | enum fluid_gen_flags
51 | {
52 | GEN_UNUSED, /**< Generator value is not set */
53 | GEN_SET, /**< Generator value is set */
54 | GEN_ABS_NRPN /**< Generator is an absolute value */
55 | };
56 |
57 | #define fluid_gen_set_mod(_gen, _val) { (_gen)->mod = (double) (_val); }
58 | #define fluid_gen_set_nrpn(_gen, _val) { (_gen)->nrpn = (double) (_val); }
59 |
60 | fluid_real_t fluid_gen_scale(int gen, float value);
61 | fluid_real_t fluid_gen_scale_nrpn(int gen, int nrpn);
62 | int fluid_gen_init(fluid_gen_t* gen, fluid_channel_t* channel);
63 | int fluid_gen_set_default_values(fluid_gen_t* gen);
64 |
65 |
66 | #endif /* _FLUID_GEN_H */
67 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/synth/fluid_mod.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUID_MOD_H
22 | #define _FLUID_MOD_H
23 |
24 | #include "fluidsynth_priv.h"
25 | #include "fluid_conv.h"
26 |
27 | /*
28 | * Modulator structure. See SoundFont 2.04 PDF section 8.2.
29 | */
30 | struct _fluid_mod_t
31 | {
32 | unsigned char dest; /**< Destination generator to control */
33 | unsigned char src1; /**< Source controller 1 */
34 | unsigned char flags1; /**< Source controller 1 flags */
35 | unsigned char src2; /**< Source controller 2 */
36 | unsigned char flags2; /**< Source controller 2 flags */
37 | double amount; /**< Multiplier amount */
38 | /* The 'next' field allows to link modulators into a list. It is
39 | * not used in fluid_voice.c, there each voice allocates memory for a
40 | * fixed number of modulators. Since there may be a huge number of
41 | * different zones, this is more efficient.
42 | */
43 | fluid_mod_t * next;
44 | };
45 |
46 | fluid_real_t fluid_mod_get_value(fluid_mod_t* mod, fluid_channel_t* chan, fluid_voice_t* voice);
47 |
48 | #ifdef DEBUG
49 | void fluid_dump_modulator(fluid_mod_t * mod);
50 | #endif
51 |
52 |
53 | #endif /* _FLUID_MOD_H */
54 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/synth/fluid_tuning.c:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #include "fluid_tuning.h"
23 | #include "fluidsynth_priv.h"
24 | #include "fluid_sys.h"
25 |
26 |
27 | fluid_tuning_t* new_fluid_tuning(const char* name, int bank, int prog)
28 | {
29 | fluid_tuning_t* tuning;
30 | int i;
31 |
32 | tuning = FLUID_NEW(fluid_tuning_t);
33 | if (tuning == NULL) {
34 | FLUID_LOG(FLUID_PANIC, "Out of memory");
35 | return NULL;
36 | }
37 | FLUID_MEMSET(tuning, 0, sizeof(fluid_tuning_t));
38 |
39 | if (fluid_tuning_set_name(tuning, name) != FLUID_OK) {
40 | delete_fluid_tuning(tuning);
41 | return NULL;
42 | }
43 |
44 | tuning->bank = bank;
45 | tuning->prog = prog;
46 |
47 | for (i = 0; i < 128; i++) {
48 | tuning->pitch[i] = i * 100.0;
49 | }
50 |
51 | fluid_atomic_int_set(&tuning->refcount, 1); /* Start with a refcount of 1 */
52 |
53 | return tuning;
54 | }
55 |
56 | /* Duplicate a tuning */
57 | fluid_tuning_t *
58 | fluid_tuning_duplicate (fluid_tuning_t *tuning)
59 | {
60 | fluid_tuning_t *new_tuning;
61 | int i;
62 |
63 | new_tuning = FLUID_NEW (fluid_tuning_t);
64 |
65 | if (!new_tuning) {
66 | FLUID_LOG (FLUID_PANIC, "Out of memory");
67 | return NULL;
68 | }
69 | FLUID_MEMSET(new_tuning, 0, sizeof(fluid_tuning_t));
70 |
71 | if (fluid_tuning_set_name(new_tuning, tuning->name) != FLUID_OK) {
72 | delete_fluid_tuning(new_tuning);
73 | return NULL;
74 | }
75 |
76 | new_tuning->bank = tuning->bank;
77 | new_tuning->prog = tuning->prog;
78 |
79 | for (i = 0; i < 128; i++)
80 | new_tuning->pitch[i] = tuning->pitch[i];
81 |
82 | fluid_atomic_int_set(&new_tuning->refcount, 1); /* Start with a refcount of 1 */
83 |
84 | return new_tuning;
85 | }
86 |
87 | void
88 | delete_fluid_tuning (fluid_tuning_t *tuning)
89 | {
90 | fluid_return_if_fail(tuning != NULL);
91 |
92 | FLUID_FREE (tuning->name);
93 | FLUID_FREE (tuning);
94 | }
95 |
96 | /* Add a reference to a tuning object */
97 | void
98 | fluid_tuning_ref (fluid_tuning_t *tuning)
99 | {
100 | fluid_return_if_fail (tuning != NULL);
101 |
102 | fluid_atomic_int_inc (&tuning->refcount);
103 | }
104 |
105 | /* Unref a tuning object, when it reaches 0 it is deleted, returns TRUE if deleted */
106 | int
107 | fluid_tuning_unref (fluid_tuning_t *tuning, int count)
108 | {
109 | fluid_return_val_if_fail (tuning != NULL, FALSE);
110 |
111 | /* Add and compare are separate, but that is OK, since refcount will only
112 | * reach 0 when there are no references and therefore no possibility of
113 | * another thread adding a reference in between */
114 | fluid_atomic_int_add (&tuning->refcount, -count);
115 |
116 | /* Delete when refcount reaches 0 */
117 | if (!fluid_atomic_int_get (&tuning->refcount))
118 | {
119 | delete_fluid_tuning (tuning);
120 | return TRUE;
121 | }
122 | else return FALSE;
123 | }
124 |
125 | int fluid_tuning_set_name(fluid_tuning_t* tuning, const char* name)
126 | {
127 | if (tuning->name != NULL) {
128 | FLUID_FREE(tuning->name);
129 | tuning->name = NULL;
130 | }
131 | if (name != NULL) {
132 | tuning->name = FLUID_STRDUP(name);
133 | if (tuning->name == NULL) {
134 | FLUID_LOG(FLUID_ERR, "Out of memory");
135 | return FLUID_FAILED;
136 | }
137 | }
138 | return FLUID_OK;
139 | }
140 |
141 | char* fluid_tuning_get_name(fluid_tuning_t* tuning)
142 | {
143 | return tuning->name;
144 | }
145 |
146 | void fluid_tuning_set_octave(fluid_tuning_t* tuning, const double* pitch_deriv)
147 | {
148 | int i;
149 |
150 | for (i = 0; i < 128; i++) {
151 | tuning->pitch[i] = i * 100.0 + pitch_deriv[i % 12];
152 | }
153 | }
154 |
155 | void fluid_tuning_set_all(fluid_tuning_t* tuning, const double* pitch)
156 | {
157 | int i;
158 |
159 | for (i = 0; i < 128; i++) {
160 | tuning->pitch[i] = pitch[i];
161 | }
162 | }
163 |
164 | void fluid_tuning_set_pitch(fluid_tuning_t* tuning, int key, double pitch)
165 | {
166 | if ((key >= 0) && (key < 128)) {
167 | tuning->pitch[key] = pitch;
168 | }
169 | }
170 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/synth/fluid_tuning.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | /*
23 |
24 | More information about micro tuning can be found at:
25 |
26 | http://www.midi.org/about-midi/tuning.htm
27 | http://www.midi.org/about-midi/tuning-scale.htm
28 | http://www.midi.org/about-midi/tuning_extens.htm
29 |
30 | */
31 |
32 | #ifndef _FLUID_TUNING_H
33 | #define _FLUID_TUNING_H
34 |
35 | #include "fluidsynth_priv.h"
36 |
37 | struct _fluid_tuning_t {
38 | char* name;
39 | int bank;
40 | int prog;
41 | double pitch[128]; /* the pitch of every key, in cents */
42 | fluid_atomic_int_t refcount; /* Tuning reference count */
43 | };
44 |
45 | fluid_tuning_t* new_fluid_tuning(const char* name, int bank, int prog);
46 | void delete_fluid_tuning (fluid_tuning_t *tuning);
47 | fluid_tuning_t *fluid_tuning_duplicate (fluid_tuning_t *tuning);
48 | void fluid_tuning_ref (fluid_tuning_t *tuning);
49 | int fluid_tuning_unref (fluid_tuning_t *tuning, int count);
50 |
51 | int fluid_tuning_set_name(fluid_tuning_t* tuning, const char* name);
52 | char* fluid_tuning_get_name(fluid_tuning_t* tuning);
53 |
54 | #define fluid_tuning_get_bank(_t) ((_t)->bank)
55 | #define fluid_tuning_get_prog(_t) ((_t)->prog)
56 |
57 | void fluid_tuning_set_pitch(fluid_tuning_t* tuning, int key, double pitch);
58 | #define fluid_tuning_get_pitch(_t, _key) ((_t)->pitch[_key])
59 |
60 | void fluid_tuning_set_octave(fluid_tuning_t* tuning, const double* pitch_deriv);
61 |
62 | void fluid_tuning_set_all(fluid_tuning_t* tuning, const double* pitch);
63 | #define fluid_tuning_get_all(_t) (&(_t)->pitch[0])
64 |
65 |
66 |
67 |
68 | #endif /* _FLUID_TUNING_H */
69 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/synth/fluid_voice.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #ifndef _FLUID_VOICE_H
23 | #define _FLUID_VOICE_H
24 |
25 | #include "fluid_phase.h"
26 | #include "fluid_gen.h"
27 | #include "fluid_mod.h"
28 | #include "fluid_iir_filter.h"
29 | #include "fluid_adsr_env.h"
30 | #include "fluid_lfo.h"
31 | #include "fluid_rvoice.h"
32 | #include "fluid_sys.h"
33 |
34 | #define NO_CHANNEL 0xff
35 |
36 | typedef struct _fluid_overflow_prio_t fluid_overflow_prio_t;
37 |
38 | struct _fluid_overflow_prio_t
39 | {
40 | float percussion; /**< Is this voice on the drum channel? Then add this score */
41 | float released; /**< Is this voice in release stage? Then add this score (usually negative) */
42 | float sustained; /**< Is this voice sustained? Then add this score (usually negative) */
43 | float volume; /**< Multiply current (or future) volume (a value between 0 and 1) */
44 | float age; /**< This score will be divided by the number of seconds the voice has lasted */
45 | float important; /**< This score will be added to all important channels */
46 | char *important_channels; /**< "important" flags indexed by MIDI channel number */
47 | int num_important_channels; /**< Number of elements in the important_channels array */
48 | };
49 |
50 | enum fluid_voice_status
51 | {
52 | FLUID_VOICE_CLEAN,
53 | FLUID_VOICE_ON,
54 | FLUID_VOICE_SUSTAINED, /* Sustained by Sustain pedal */
55 | FLUID_VOICE_HELD_BY_SOSTENUTO, /* Sustained by Sostenuto pedal */
56 | FLUID_VOICE_OFF
57 | };
58 |
59 |
60 | /*
61 | * fluid_voice_t
62 | */
63 | struct _fluid_voice_t
64 | {
65 | unsigned int id; /* the id is incremented for every new noteon.
66 | it's used for noteoff's */
67 | unsigned char status;
68 | unsigned char chan; /* the channel number, quick access for channel messages */
69 | unsigned char key; /* the key of the noteon event, quick access for noteoff */
70 | unsigned char vel; /* the velocity of the noteon event */
71 | fluid_channel_t* channel;
72 | fluid_gen_t gen[GEN_LAST];
73 | fluid_mod_t mod[FLUID_NUM_MOD];
74 | int mod_count;
75 | fluid_zone_range_t * zone_range; /* instrument zone range*/
76 | fluid_sample_t* sample; /* Pointer to sample (dupe in rvoice) */
77 |
78 | /* basic parameters */
79 | fluid_real_t output_rate; /* the sample rate of the synthesizer (dupe in rvoice) */
80 |
81 | unsigned int start_time;
82 | fluid_adsr_env_t volenv; /* Volume envelope (dupe in rvoice) */
83 |
84 | /* basic parameters */
85 | fluid_real_t pitch; /* the pitch in midicents (dupe in rvoice) */
86 | fluid_real_t attenuation; /* the attenuation in centibels (dupe in rvoice) */
87 | fluid_real_t root_pitch;
88 |
89 | /* master gain (dupe in rvoice) */
90 | fluid_real_t synth_gain;
91 |
92 | /* pan */
93 | fluid_real_t pan;
94 |
95 | /* balance */
96 | fluid_real_t balance;
97 |
98 | /* reverb */
99 | fluid_real_t reverb_send;
100 |
101 | /* chorus */
102 | fluid_real_t chorus_send;
103 |
104 | /* rvoice control */
105 | fluid_rvoice_t* rvoice;
106 | fluid_rvoice_t* overflow_rvoice; /* Used temporarily and only in overflow situations */
107 | char can_access_rvoice; /* False if rvoice is being rendered in separate thread */
108 | char can_access_overflow_rvoice; /* False if overflow_rvoice is being rendered in separate thread */
109 | char has_noteoff; /* Flag set when noteoff has been sent */
110 |
111 | #ifdef WITH_PROFILING
112 | /* for debugging */
113 | double ref;
114 | #endif
115 | };
116 |
117 |
118 | fluid_voice_t* new_fluid_voice(fluid_real_t output_rate);
119 | void delete_fluid_voice(fluid_voice_t* voice);
120 |
121 | void fluid_voice_start(fluid_voice_t* voice);
122 | void fluid_voice_calculate_gen_pitch(fluid_voice_t* voice);
123 |
124 | int fluid_voice_write (fluid_voice_t* voice, fluid_real_t *dsp_buf);
125 |
126 | int fluid_voice_init(fluid_voice_t* voice, fluid_sample_t* sample,
127 | fluid_zone_range_t *inst_zone_range,
128 | fluid_channel_t* channel, int key, int vel,
129 | unsigned int id, unsigned int time, fluid_real_t gain);
130 |
131 | int fluid_voice_modulate(fluid_voice_t* voice, int cc, int ctrl);
132 | int fluid_voice_modulate_all(fluid_voice_t* voice);
133 |
134 | /** Set the NRPN value of a generator. */
135 | int fluid_voice_set_param(fluid_voice_t* voice, int gen, fluid_real_t value, int abs);
136 |
137 |
138 | /** Set the gain. */
139 | int fluid_voice_set_gain(fluid_voice_t* voice, fluid_real_t gain);
140 |
141 | int fluid_voice_set_output_rate(fluid_voice_t* voice, fluid_real_t value);
142 |
143 |
144 | /** Update all the synthesis parameters, which depend on generator
145 | 'gen'. This is only necessary after changing a generator of an
146 | already operating voice. Most applications will not need this
147 | function.*/
148 | void fluid_voice_update_param(fluid_voice_t* voice, int gen);
149 |
150 | /** legato modes */
151 | /* force in the attack section for legato mode multi_retrigger: 1 */
152 | void fluid_voice_update_multi_retrigger_attack(fluid_voice_t* voice,int tokey, int vel);
153 | /* Update portamento parameter */
154 | void fluid_voice_update_portamento (fluid_voice_t* voice, int fromkey, int tokey);
155 |
156 |
157 | void fluid_voice_release(fluid_voice_t* voice);
158 | void fluid_voice_noteoff(fluid_voice_t* voice);
159 | void fluid_voice_off(fluid_voice_t* voice);
160 | void fluid_voice_stop(fluid_voice_t* voice);
161 | void fluid_voice_overflow_rvoice_finished(fluid_voice_t* voice);
162 |
163 | int fluid_voice_kill_excl(fluid_voice_t* voice);
164 | float fluid_voice_get_overflow_prio(fluid_voice_t* voice,
165 | fluid_overflow_prio_t* score,
166 | unsigned int cur_time);
167 |
168 | #define OVERFLOW_PRIO_CANNOT_KILL 999999.
169 |
170 | /**
171 | * Locks the rvoice for rendering, so it can't be modified directly
172 | */
173 | static FLUID_INLINE fluid_rvoice_t*
174 | fluid_voice_lock_rvoice(fluid_voice_t* voice)
175 | {
176 | voice->can_access_rvoice = 0;
177 | return voice->rvoice;
178 | }
179 |
180 | /**
181 | * Unlocks the rvoice for rendering, so it can be modified directly
182 | */
183 | static FLUID_INLINE void
184 | fluid_voice_unlock_rvoice(fluid_voice_t* voice)
185 | {
186 | voice->can_access_rvoice = 1;
187 | }
188 |
189 | #define _AVAILABLE(voice) ((voice)->can_access_rvoice && \
190 | (((voice)->status == FLUID_VOICE_CLEAN) || ((voice)->status == FLUID_VOICE_OFF)))
191 | //#define _RELEASED(voice) ((voice)->chan == NO_CHANNEL)
192 | #define _SAMPLEMODE(voice) ((int)(voice)->gen[GEN_SAMPLEMODE].val)
193 |
194 |
195 | fluid_real_t fluid_voice_gen_value(const fluid_voice_t* voice, int num);
196 | void fluid_voice_set_custom_filter(fluid_voice_t* voice, enum fluid_iir_filter_type type, enum fluid_iir_filter_flags flags);
197 |
198 | #define fluid_voice_get_loudness(voice) (fluid_adsr_env_get_max_val(&voice->volenv))
199 |
200 |
201 | #endif /* _FLUID_VOICE_H */
202 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/utils/fluid_atomic.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _FLUID_ATOMIC_H
3 | #define _FLUID_ATOMIC_H
4 |
5 | #include
6 |
7 | #ifndef STATIC_ASSERT
8 | #if __STDC_VERSION__ >= 201112L
9 | #define STATIC_ASSERT _Static_assert
10 | #else
11 | #define STATIC_ASSERT(expr, msg) typedef char __static_assertion_ ## __COUNTER__[(expr) ? 1 : -1]
12 | #endif
13 | #endif //STATIC_ASSERT
14 |
15 | #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
16 |
17 | #define fluid_atomic_int_add(atomic, val) __extension__ ({ \
18 | STATIC_ASSERT(sizeof((atomic)->value) == sizeof(int), \
19 | "Atomic must be the size of an int"); \
20 | __sync_fetch_and_add(&(atomic)->value, (val));})
21 |
22 | #define fluid_atomic_int_get(atomic) __extension__ ({ \
23 | STATIC_ASSERT(sizeof((atomic)->value) == sizeof(int), \
24 | "Atomic must be the size of an int"); \
25 | __sync_synchronize(); \
26 | (atomic)->value;})
27 |
28 | #define fluid_atomic_int_set(atomic, newval) __extension__ ({ \
29 | STATIC_ASSERT(sizeof((atomic)->value) == sizeof(int), \
30 | "Atomic must be the size of an int"); \
31 | (atomic)->value = (newval); \
32 | __sync_synchronize();})
33 |
34 | #define fluid_atomic_int_inc(atomic) __extension__ ({ \
35 | STATIC_ASSERT(sizeof((atomic)->value) == sizeof(int), \
36 | "Atomic must be the size of an int"); \
37 | __sync_synchronize(); \
38 | __sync_fetch_and_add(&(atomic)->value, 1);})
39 |
40 | #define fluid_atomic_int_compare_and_exchange(atomic, oldval, newval) __extension__ ({ \
41 | STATIC_ASSERT(sizeof((atomic)->value) == sizeof(int), \
42 | "Atomic must be the size of an int"); \
43 | __sync_bool_compare_and_swap(&(atomic)->value, (oldval), (newval));})
44 |
45 | #define fluid_atomic_int_exchange_and_add(atomic, add) __extension__ ({ \
46 | STATIC_ASSERT(sizeof((atomic)->value) == sizeof(int), \
47 | "Atomic must be the size of an int"); \
48 | __sync_synchronize(); \
49 | __sync_fetch_and_add(&(atomic)->value, add);})
50 |
51 | #define fluid_atomic_float_get(atomic) __extension__ ({ \
52 | STATIC_ASSERT(sizeof((atomic)->value) == sizeof(float), \
53 | "Atomic must be the size of a float"); \
54 | __sync_synchronize(); \
55 | (atomic)->value;})
56 |
57 | #define fluid_atomic_float_set(atomic, val) __extension__ ({ \
58 | STATIC_ASSERT(sizeof((atomic)->value) == sizeof(float), \
59 | "Atomic must be the size of a float"); \
60 | (atomic)->value = (val); \
61 | __sync_synchronize();})
62 |
63 | #else
64 |
65 | #error "GCC builtins missings for atomic operations"
66 |
67 | #endif
68 |
69 | #endif /* _FLUID_ATOMIC_H */
70 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/utils/fluid_conv.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUID_CONV_H
22 | #define _FLUID_CONV_H
23 |
24 | #include "fluidsynth_priv.h"
25 |
26 | #define FLUID_CENTS_HZ_SIZE 1200
27 | #define FLUID_VEL_CB_SIZE 128
28 | #define FLUID_CB_AMP_SIZE 1441
29 | #define FLUID_PAN_SIZE 1002
30 |
31 | void fluid_conversion_config(void);
32 |
33 | fluid_real_t fluid_ct2hz_real(fluid_real_t cents);
34 | fluid_real_t fluid_ct2hz(fluid_real_t cents);
35 | fluid_real_t fluid_cb2amp(fluid_real_t cb);
36 | fluid_real_t fluid_tc2sec(fluid_real_t tc);
37 | fluid_real_t fluid_tc2sec_delay(fluid_real_t tc);
38 | fluid_real_t fluid_tc2sec_attack(fluid_real_t tc);
39 | fluid_real_t fluid_tc2sec_release(fluid_real_t tc);
40 | fluid_real_t fluid_act2hz(fluid_real_t c);
41 | fluid_real_t fluid_hz2ct(fluid_real_t c);
42 | fluid_real_t fluid_pan(fluid_real_t c, int left);
43 | fluid_real_t fluid_balance(fluid_real_t balance, int left);
44 | fluid_real_t fluid_concave(fluid_real_t val);
45 | fluid_real_t fluid_convex(fluid_real_t val);
46 |
47 | extern fluid_real_t fluid_ct2hz_tab[FLUID_CENTS_HZ_SIZE];
48 | extern fluid_real_t fluid_vel2cb_tab[FLUID_VEL_CB_SIZE];
49 | extern fluid_real_t fluid_cb2amp_tab[FLUID_CB_AMP_SIZE];
50 | extern fluid_real_t fluid_concave_tab[128];
51 | extern fluid_real_t fluid_convex_tab[128];
52 | extern fluid_real_t fluid_pan_tab[FLUID_PAN_SIZE];
53 |
54 |
55 | #endif /* _FLUID_CONV_H */
56 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/utils/fluid_hash.h:
--------------------------------------------------------------------------------
1 | /* GLIB - Library of useful routines for C programming
2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the
16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 | * Boston, MA 02110-1301, USA.
18 | */
19 |
20 | /*
21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS
22 | * file for a list of people on the GLib Team. See the ChangeLog
23 | * files for a list of changes. These files are distributed with
24 | * GLib at ftp://ftp.gtk.org/pub/gtk/.
25 | */
26 |
27 | /*
28 | * Adapted for FluidSynth use by Josh Green
29 | * September 8, 2009 from glib 2.18.4
30 | *
31 | * - Self contained (no dependencies on glib)
32 | * - changed names to fluid_hashtable_...
33 | */
34 |
35 | #ifndef _FLUID_HASH_H
36 | #define _FLUID_HASH_H
37 |
38 | #include "fluidsynth_priv.h"
39 | #include "fluid_list.h"
40 | #include "fluid_sys.h"
41 |
42 | /* Extracted from gtypes.h */
43 | typedef void (*fluid_destroy_notify_t)(void *data);
44 | typedef unsigned int (*fluid_hash_func_t)(const void *key);
45 | typedef int (*fluid_equal_func_t)(const void *a, const void *b);
46 | /* End gtypes.h extraction */
47 |
48 | typedef int (*fluid_hr_func_t)(void *key, void *value, void *user_data);
49 | typedef struct _fluid_hashtable_iter_t fluid_hashtable_iter_t;
50 |
51 | typedef struct _fluid_hashnode_t fluid_hashnode_t;
52 |
53 | struct _fluid_hashnode_t
54 | {
55 | void *key;
56 | void *value;
57 | fluid_hashnode_t *next;
58 | unsigned int key_hash;
59 | };
60 |
61 | struct _fluid_hashtable_t
62 | {
63 | int size;
64 | int nnodes;
65 | fluid_hashnode_t **nodes;
66 | fluid_hash_func_t hash_func;
67 | fluid_equal_func_t key_equal_func;
68 | fluid_atomic_int_t ref_count;
69 | fluid_destroy_notify_t key_destroy_func;
70 | fluid_destroy_notify_t value_destroy_func;
71 | fluid_rec_mutex_t mutex; // Optionally used in other modules (fluid_settings.c for example)
72 | };
73 |
74 | struct _fluid_hashtable_iter_t
75 | {
76 | /*< private >*/
77 | void * dummy1;
78 | void * dummy2;
79 | void * dummy3;
80 | int dummy4;
81 | int dummy5; // Bool
82 | void * dummy6;
83 | };
84 |
85 | fluid_hashtable_t* new_fluid_hashtable (fluid_hash_func_t hash_func,
86 | fluid_equal_func_t key_equal_func);
87 | fluid_hashtable_t* new_fluid_hashtable_full (fluid_hash_func_t hash_func,
88 | fluid_equal_func_t key_equal_func,
89 | fluid_destroy_notify_t key_destroy_func,
90 | fluid_destroy_notify_t value_destroy_func);
91 | void delete_fluid_hashtable(fluid_hashtable_t *hashtable);
92 |
93 | void fluid_hashtable_iter_init (fluid_hashtable_iter_t *iter, fluid_hashtable_t *hashtable);
94 | int fluid_hashtable_iter_next (fluid_hashtable_iter_t *iter, void **key, void **value);
95 | fluid_hashtable_t *fluid_hashtable_iter_get_hash_table (fluid_hashtable_iter_t *iter);
96 | void fluid_hashtable_iter_remove (fluid_hashtable_iter_t *iter);
97 | void fluid_hashtable_iter_steal (fluid_hashtable_iter_t *iter);
98 |
99 | fluid_hashtable_t* fluid_hashtable_ref (fluid_hashtable_t *hashtable);
100 | void fluid_hashtable_unref (fluid_hashtable_t *hashtable);
101 |
102 | void *fluid_hashtable_lookup (fluid_hashtable_t *hashtable, const void *key);
103 | int fluid_hashtable_lookup_extended (fluid_hashtable_t *hashtable, const void *lookup_key,
104 | void **orig_key, void **value);
105 |
106 | void fluid_hashtable_insert (fluid_hashtable_t *hashtable, void *key, void *value);
107 | void fluid_hashtable_replace (fluid_hashtable_t *hashtable, void *key, void *value);
108 |
109 | int fluid_hashtable_remove (fluid_hashtable_t *hashtable, const void *key);
110 | int fluid_hashtable_steal (fluid_hashtable_t *hashtable, const void *key);
111 | void fluid_hashtable_remove_all (fluid_hashtable_t *hashtable);
112 | void fluid_hashtable_steal_all (fluid_hashtable_t *hashtable);
113 | unsigned int fluid_hashtable_foreach_steal (fluid_hashtable_t *hashtable,
114 | fluid_hr_func_t func, void *user_data);
115 | void fluid_hashtable_foreach (fluid_hashtable_t *hashtable, fluid_hr_func_t func,
116 | void *user_data);
117 | void *fluid_hashtable_find (fluid_hashtable_t *hashtable, fluid_hr_func_t predicate,
118 | void *user_data);
119 | unsigned int fluid_hashtable_size (fluid_hashtable_t *hashtable);
120 | fluid_list_t *fluid_hashtable_get_keys (fluid_hashtable_t *hashtable);
121 | fluid_list_t *fluid_hashtable_get_values (fluid_hashtable_t *hashtable);
122 |
123 | int fluid_str_equal (const void *v1, const void *v2);
124 | unsigned int fluid_str_hash (const void *v);
125 | int fluid_direct_equal (const void *v1, const void *v2);
126 | unsigned int fluid_direct_hash (const void *v);
127 | int fluid_int_equal (const void *v1, const void *v2);
128 | unsigned int fluid_int_hash (const void *v);
129 |
130 | #endif /* _FLUID_HASH_H */
131 |
132 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/utils/fluid_list.c:
--------------------------------------------------------------------------------
1 | /* GLIB - Library of useful routines for C programming
2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the
16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 | * Boston, MA 02110-1301, USA.
18 | */
19 |
20 | /*
21 | * Modified by the GLib Team and others 1997-1999. See the AUTHORS
22 | * file for a list of people on the GLib Team. See the ChangeLog
23 | * files for a list of changes. These files are distributed with
24 | * GLib at ftp://ftp.gtk.org/pub/gtk/.
25 | */
26 |
27 |
28 |
29 | #include "fluid_sys.h"
30 | #include "fluid_list.h"
31 |
32 |
33 | fluid_list_t*
34 | new_fluid_list(void)
35 | {
36 | fluid_list_t* list;
37 | list = (fluid_list_t*) FLUID_MALLOC(sizeof(fluid_list_t));
38 | list->data = NULL;
39 | list->next = NULL;
40 | return list;
41 | }
42 |
43 | void
44 | delete_fluid_list(fluid_list_t *list)
45 | {
46 | fluid_list_t *next;
47 | fluid_return_if_fail(list != NULL);
48 |
49 | while (list) {
50 | next = list->next;
51 | FLUID_FREE(list);
52 | list = next;
53 | }
54 | }
55 |
56 | void
57 | delete1_fluid_list(fluid_list_t *list)
58 | {
59 | FLUID_FREE(list);
60 | }
61 |
62 | fluid_list_t*
63 | fluid_list_append(fluid_list_t *list, void* data)
64 | {
65 | fluid_list_t *new_list;
66 | fluid_list_t *last;
67 |
68 | new_list = new_fluid_list();
69 | new_list->data = data;
70 |
71 | if (list)
72 | {
73 | last = fluid_list_last(list);
74 | /* g_assert (last != NULL); */
75 | last->next = new_list;
76 |
77 | return list;
78 | }
79 | else
80 | return new_list;
81 | }
82 |
83 | fluid_list_t*
84 | fluid_list_prepend(fluid_list_t *list, void* data)
85 | {
86 | fluid_list_t *new_list;
87 |
88 | new_list = new_fluid_list();
89 | new_list->data = data;
90 | new_list->next = list;
91 |
92 | return new_list;
93 | }
94 |
95 | fluid_list_t*
96 | fluid_list_nth(fluid_list_t *list, int n)
97 | {
98 | while ((n-- > 0) && list) {
99 | list = list->next;
100 | }
101 |
102 | return list;
103 | }
104 |
105 | fluid_list_t*
106 | fluid_list_remove(fluid_list_t *list, void* data)
107 | {
108 | fluid_list_t *tmp;
109 | fluid_list_t *prev;
110 |
111 | prev = NULL;
112 | tmp = list;
113 |
114 | while (tmp) {
115 | if (tmp->data == data) {
116 | if (prev) {
117 | prev->next = tmp->next;
118 | }
119 | if (list == tmp) {
120 | list = list->next;
121 | }
122 | tmp->next = NULL;
123 | delete_fluid_list(tmp);
124 |
125 | break;
126 | }
127 |
128 | prev = tmp;
129 | tmp = tmp->next;
130 | }
131 |
132 | return list;
133 | }
134 |
135 | fluid_list_t*
136 | fluid_list_remove_link(fluid_list_t *list, fluid_list_t *link)
137 | {
138 | fluid_list_t *tmp;
139 | fluid_list_t *prev;
140 |
141 | prev = NULL;
142 | tmp = list;
143 |
144 | while (tmp) {
145 | if (tmp == link) {
146 | if (prev) {
147 | prev->next = tmp->next;
148 | }
149 | if (list == tmp) {
150 | list = list->next;
151 | }
152 | tmp->next = NULL;
153 | break;
154 | }
155 |
156 | prev = tmp;
157 | tmp = tmp->next;
158 | }
159 |
160 | return list;
161 | }
162 |
163 | static fluid_list_t*
164 | fluid_list_sort_merge(fluid_list_t *l1, fluid_list_t *l2, fluid_compare_func_t compare_func)
165 | {
166 | fluid_list_t list, *l;
167 |
168 | l = &list;
169 |
170 | while (l1 && l2) {
171 | if (compare_func(l1->data,l2->data) < 0) {
172 | l = l->next = l1;
173 | l1 = l1->next;
174 | } else {
175 | l = l->next = l2;
176 | l2 = l2->next;
177 | }
178 | }
179 | l->next= l1 ? l1 : l2;
180 |
181 | return list.next;
182 | }
183 |
184 | fluid_list_t*
185 | fluid_list_sort(fluid_list_t *list, fluid_compare_func_t compare_func)
186 | {
187 | fluid_list_t *l1, *l2;
188 |
189 | if (!list) {
190 | return NULL;
191 | }
192 | if (!list->next) {
193 | return list;
194 | }
195 |
196 | l1 = list;
197 | l2 = list->next;
198 |
199 | while ((l2 = l2->next) != NULL) {
200 | if ((l2 = l2->next) == NULL)
201 | break;
202 | l1=l1->next;
203 | }
204 | l2 = l1->next;
205 | l1->next = NULL;
206 |
207 | return fluid_list_sort_merge(fluid_list_sort(list, compare_func),
208 | fluid_list_sort(l2, compare_func),
209 | compare_func);
210 | }
211 |
212 |
213 | fluid_list_t*
214 | fluid_list_last(fluid_list_t *list)
215 | {
216 | if (list) {
217 | while (list->next)
218 | list = list->next;
219 | }
220 |
221 | return list;
222 | }
223 |
224 | int
225 | fluid_list_size(fluid_list_t *list)
226 | {
227 | int n = 0;
228 | while (list) {
229 | n++;
230 | list = list->next;
231 | }
232 | return n;
233 | }
234 |
235 | fluid_list_t* fluid_list_insert_at(fluid_list_t *list, int n, void* data)
236 | {
237 | fluid_list_t *new_list;
238 | fluid_list_t *cur;
239 | fluid_list_t *prev = NULL;
240 |
241 | new_list = new_fluid_list();
242 | new_list->data = data;
243 |
244 | cur = list;
245 | while ((n-- > 0) && cur) {
246 | prev = cur;
247 | cur = cur->next;
248 | }
249 |
250 | new_list->next = cur;
251 |
252 | if (prev) {
253 | prev->next = new_list;
254 | return list;
255 | } else {
256 | return new_list;
257 | }
258 | }
259 |
260 | /* Compare function to sort strings alphabetically,
261 | * for use with fluid_list_sort(). */
262 | int
263 | fluid_list_str_compare_func (void *a, void *b)
264 | {
265 | if (a && b) return FLUID_STRCMP ((char *)a, (char *)b);
266 | if (!a && !b) return 0;
267 | if (a) return -1;
268 | return 1;
269 | }
270 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/utils/fluid_list.h:
--------------------------------------------------------------------------------
1 | /* GLIB - Library of useful routines for C programming
2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the
16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 | * Boston, MA 02110-1301, USA.
18 | */
19 |
20 | #ifndef _FLUID_LIST_H
21 | #define _FLUID_LIST_H
22 |
23 | #include "fluidsynth_priv.h"
24 |
25 | /*
26 | *
27 | * Lists
28 | *
29 | * A sound font loader has to pack the data from the .SF2 file into
30 | * list structures of this type.
31 | *
32 | */
33 |
34 | typedef struct _fluid_list_t fluid_list_t;
35 |
36 | typedef int (*fluid_compare_func_t)(void* a, void* b);
37 |
38 | struct _fluid_list_t
39 | {
40 | void* data;
41 | fluid_list_t *next;
42 | };
43 |
44 | fluid_list_t* new_fluid_list(void);
45 | void delete_fluid_list(fluid_list_t *list);
46 | void delete1_fluid_list(fluid_list_t *list);
47 | fluid_list_t* fluid_list_sort(fluid_list_t *list, fluid_compare_func_t compare_func);
48 | fluid_list_t* fluid_list_append(fluid_list_t *list, void* data);
49 | fluid_list_t* fluid_list_prepend(fluid_list_t *list, void* data);
50 | fluid_list_t* fluid_list_remove(fluid_list_t *list, void* data);
51 | fluid_list_t* fluid_list_remove_link(fluid_list_t *list, fluid_list_t *llink);
52 | fluid_list_t* fluid_list_nth(fluid_list_t *list, int n);
53 | fluid_list_t* fluid_list_last(fluid_list_t *list);
54 | fluid_list_t* fluid_list_insert_at(fluid_list_t *list, int n, void* data);
55 | int fluid_list_size(fluid_list_t *list);
56 |
57 | #define fluid_list_next(slist) ((slist) ? (((fluid_list_t *)(slist))->next) : NULL)
58 | #define fluid_list_get(slist) ((slist) ? ((slist)->data) : NULL)
59 |
60 | int fluid_list_str_compare_func (void *a, void *b);
61 |
62 | #endif /* _FLUID_LIST_H */
63 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/utils/fluid_ringbuffer.c:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | /*
22 | * Josh Green
23 | * 2009-05-28
24 | */
25 |
26 | #include "fluid_ringbuffer.h"
27 | #include "fluidsynth_priv.h"
28 |
29 |
30 | /**
31 | * Create a lock free queue with a fixed maximum count and size of elements.
32 | * @param count Count of elements in queue (fixed max number of queued elements)
33 | * @return New lock free queue or NULL if out of memory (error message logged)
34 | *
35 | * Lockless FIFO queues don't use any locking mechanisms and can therefore be
36 | * advantageous in certain situations, such as passing data between a lower
37 | * priority thread and a higher "real time" thread, without potential lock
38 | * contention which could stall the high priority thread. Note that there may
39 | * only be one producer thread and one consumer thread.
40 | */
41 | fluid_ringbuffer_t *
42 | new_fluid_ringbuffer (int count, int elementsize)
43 | {
44 | fluid_ringbuffer_t *queue;
45 |
46 | fluid_return_val_if_fail (count > 0, NULL);
47 |
48 | queue = FLUID_NEW (fluid_ringbuffer_t);
49 |
50 | if (!queue)
51 | {
52 | FLUID_LOG (FLUID_ERR, "Out of memory");
53 | return NULL;
54 | }
55 |
56 | queue->array = FLUID_MALLOC (elementsize * count);
57 |
58 | if (!queue->array)
59 | {
60 | FLUID_LOG (FLUID_ERR, "Out of memory");
61 | delete_fluid_ringbuffer(queue);
62 | return NULL;
63 | }
64 |
65 | /* Clear array, in case dynamic pointer reclaiming is being done */
66 | FLUID_MEMSET (queue->array, 0, elementsize * count);
67 |
68 | queue->totalcount = count;
69 | queue->elementsize = elementsize;
70 | fluid_atomic_int_set(&queue->count, 0);
71 | queue->in = 0;
72 | queue->out = 0;
73 |
74 | return (queue);
75 | }
76 |
77 | /**
78 | * Free an event queue.
79 | * @param queue Lockless queue instance
80 | *
81 | * Care must be taken when freeing a queue, to ensure that the consumer and
82 | * producer threads will no longer access it.
83 | */
84 | void
85 | delete_fluid_ringbuffer (fluid_ringbuffer_t *queue)
86 | {
87 | fluid_return_if_fail(queue != NULL);
88 | FLUID_FREE (queue->array);
89 | FLUID_FREE (queue);
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/utils/fluid_ringbuffer.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 | #ifndef _FLUID_RINGBUFFER_H
22 | #define _FLUID_RINGBUFFER_H
23 |
24 | #include "fluid_sys.h"
25 |
26 | /*
27 | * Lockless event queue instance.
28 | */
29 | struct _fluid_ringbuffer_t
30 | {
31 | char *array; /**< Queue array of arbitrary size elements */
32 | int totalcount; /**< Total count of elements in array */
33 | fluid_atomic_int_t count; /**< Current count of elements */
34 | int in; /**< Index in queue to store next pushed element */
35 | int out; /**< Index in queue of next popped element */
36 | int elementsize; /**< Size of each element */
37 | void* userdata;
38 | };
39 |
40 | typedef struct _fluid_ringbuffer_t fluid_ringbuffer_t;
41 |
42 |
43 | fluid_ringbuffer_t *new_fluid_ringbuffer (int count, int elementsize);
44 | void delete_fluid_ringbuffer (fluid_ringbuffer_t *queue);
45 |
46 | /**
47 | * Get pointer to next input array element in queue.
48 | * @param queue Lockless queue instance
49 | * @param offset Normally zero, or more if you need to push several items at once
50 | * @return Pointer to array element in queue to store data to or NULL if queue is full
51 | *
52 | * This function along with fluid_ringbuffer_next_inptr() form a queue "push"
53 | * operation and is split into 2 functions to avoid an element copy. Note that
54 | * the returned array element pointer may contain the data of a previous element
55 | * if the queue has wrapped around. This can be used to reclaim pointers to
56 | * allocated memory, etc.
57 | */
58 | static FLUID_INLINE void*
59 | fluid_ringbuffer_get_inptr (fluid_ringbuffer_t *queue, int offset)
60 | {
61 | return fluid_atomic_int_get (&queue->count) + offset >= queue->totalcount ? NULL
62 | : queue->array + queue->elementsize * ((queue->in + offset) % queue->totalcount);
63 | }
64 |
65 | /**
66 | * Advance the input queue index to complete a "push" operation.
67 | * @param queue Lockless queue instance
68 | * @param count Normally one, or more if you need to push several items at once
69 | *
70 | * This function along with fluid_ringbuffer_get_inptr() form a queue "push"
71 | * operation and is split into 2 functions to avoid element copy.
72 | */
73 | static FLUID_INLINE void
74 | fluid_ringbuffer_next_inptr (fluid_ringbuffer_t *queue, int count)
75 | {
76 | fluid_atomic_int_add (&queue->count, count);
77 |
78 | queue->in += count;
79 | if (queue->in >= queue->totalcount)
80 | queue->in -= queue->totalcount;
81 | }
82 |
83 | /**
84 | * Get amount of items currently in queue
85 | * @param queue Lockless queue instance
86 | * @return amount of items currently in queue
87 | */
88 | static FLUID_INLINE int
89 | fluid_ringbuffer_get_count (fluid_ringbuffer_t *queue)
90 | {
91 | return fluid_atomic_int_get (&queue->count);
92 | }
93 |
94 |
95 | /**
96 | * Get pointer to next output array element in queue.
97 | * @param queue Lockless queue instance
98 | * @return Pointer to array element data in the queue or NULL if empty, can only
99 | * be used up until fluid_ringbuffer_next_outptr() is called.
100 | *
101 | * This function along with fluid_ringbuffer_next_outptr() form a queue "pop"
102 | * operation and is split into 2 functions to avoid an element copy.
103 | */
104 | static FLUID_INLINE void*
105 | fluid_ringbuffer_get_outptr (fluid_ringbuffer_t *queue)
106 | {
107 | return fluid_ringbuffer_get_count(queue) == 0 ? NULL
108 | : queue->array + queue->elementsize * queue->out;
109 | }
110 |
111 |
112 | /**
113 | * Advance the output queue index to complete a "pop" operation.
114 | * @param queue Lockless queue instance
115 | *
116 | * This function along with fluid_ringbuffer_get_outptr() form a queue "pop"
117 | * operation and is split into 2 functions to avoid an element copy.
118 | */
119 | static FLUID_INLINE void
120 | fluid_ringbuffer_next_outptr (fluid_ringbuffer_t *queue)
121 | {
122 | fluid_atomic_int_add (&queue->count, -1);
123 |
124 | if (++queue->out == queue->totalcount)
125 | queue->out = 0;
126 | }
127 |
128 | #endif /* _FLUID_ringbuffer_H */
129 |
--------------------------------------------------------------------------------
/app/src/main/cpp/fluidsynth/src/utils/fluid_settings.h:
--------------------------------------------------------------------------------
1 | /* FluidSynth - A Software Synthesizer
2 | *
3 | * Copyright (C) 2003 Peter Hanappe and others.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free
17 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 | * 02110-1301, USA
19 | */
20 |
21 |
22 | #ifndef _FLUID_SETTINGS_H
23 | #define _FLUID_SETTINGS_H
24 |
25 | int fluid_settings_add_option(fluid_settings_t* settings, const char* name, const char* s);
26 | int fluid_settings_remove_option(fluid_settings_t* settings, const char* name, const char* s);
27 |
28 |
29 | typedef void (*fluid_str_update_t)(void* data, const char* name, const char* value);
30 |
31 | int fluid_settings_register_str(fluid_settings_t* settings, const char* name, const char* def, int hints);
32 | int fluid_settings_callback_str(fluid_settings_t* settings, const char* name,
33 | fluid_str_update_t fun, void* data);
34 |
35 |
36 | typedef void (*fluid_num_update_t)(void* data, const char* name, double value);
37 |
38 | int fluid_settings_register_num(fluid_settings_t* settings, const char* name, double def,
39 | double min, double max, int hints);
40 | int fluid_settings_callback_num(fluid_settings_t* settings, const char* name,
41 | fluid_num_update_t fun, void* data);
42 |
43 | /* Type specific wrapper for fluid_settings_getnum */
44 | int fluid_settings_getnum_float(fluid_settings_t *settings, const char *name, float *val);
45 |
46 |
47 | typedef void (*fluid_int_update_t)(void* data, const char* name, int value);
48 | int fluid_settings_register_int(fluid_settings_t* settings, const char* name, int def,
49 | int min, int max, int hints);
50 | int fluid_settings_callback_int(fluid_settings_t* settings, const char* name,
51 | fluid_int_update_t fun, void* data);
52 |
53 | int fluid_settings_split_csv(const char *str, int *buf, int buf_len);
54 |
55 | #endif /* _FLUID_SETTINGS_H */
56 |
--------------------------------------------------------------------------------
/app/src/main/cpp/native-lib.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | fluid_settings_t *settings;
5 | fluid_synth_t *synth;
6 | fluid_audio_driver_t *adriver;
7 |
8 | extern "C"
9 | JNIEXPORT void JNICALL Java_opensles_android_fluidsynth_fluidsynth_1android_1opensles_NativeLibJNI_init(
10 | JNIEnv *env,
11 | jobject /* this */,
12 | jstring sf2path) {
13 | // Init settings
14 | settings = new_fluid_settings();
15 | fluid_settings_setstr(settings, "audio.driver", "opensles");
16 | fluid_settings_setint(settings, "audio.opensles.use-callback-mode", 1);
17 | fluid_settings_setint(settings, "audio.period-size", 64);
18 |
19 | synth = new_fluid_synth(settings);
20 |
21 | // Init soundfont
22 | const char *nativeSf2Path = env->GetStringUTFChars(sf2path, NULL);
23 | fluid_synth_sfload(synth, nativeSf2Path, true);
24 | env->ReleaseStringUTFChars(sf2path, nativeSf2Path);
25 |
26 | adriver = new_fluid_audio_driver(settings, synth);
27 | }
28 |
29 | extern "C"
30 | JNIEXPORT void JNICALL Java_opensles_android_fluidsynth_fluidsynth_1android_1opensles_NativeLibJNI_noteOn(
31 | JNIEnv *env,
32 | jobject /* this */,
33 | jint key,
34 | jint velocity) {
35 | fluid_synth_noteon(synth, 0, key, velocity);
36 | }
37 |
38 | extern "C"
39 | JNIEXPORT void JNICALL Java_opensles_android_fluidsynth_fluidsynth_1android_1opensles_NativeLibJNI_noteOff(
40 | JNIEnv *env,
41 | jobject /* this */,
42 | jint key) {
43 | fluid_synth_noteoff(synth, 0, key);
44 | }
45 |
46 | extern "C"
47 | JNIEXPORT jboolean JNICALL Java_opensles_android_fluidsynth_fluidsynth_1android_1opensles_NativeLibJNI_programChange(
48 | JNIEnv *env,
49 | jobject /* this */,
50 | jint channel,
51 | jint programNumber) {
52 | return (jboolean) (FLUID_OK == fluid_synth_program_change(synth, (int) channel, (int) programNumber));
53 | }
54 |
55 | extern "C"
56 | JNIEXPORT void JNICALL Java_opensles_android_fluidsynth_fluidsynth_1android_1opensles_NativeLibJNI_destroy(
57 | JNIEnv *env,
58 | jobject /* this */) {
59 | delete_fluid_audio_driver(adriver);
60 | delete_fluid_synth(synth);
61 | delete_fluid_settings(settings);
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/opensles/android/fluidsynth/fluidsynth_android_opensles/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package opensles.android.fluidsynth.fluidsynth_android_opensles
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import android.view.MotionEvent
6 | import android.view.View
7 | import kotlinx.android.synthetic.main.activity_main.*
8 | import okio.Okio
9 | import java.io.File
10 |
11 | class MainActivity : AppCompatActivity(), View.OnTouchListener {
12 |
13 | companion object {
14 |
15 | private const val SF2_FILE_NAME = "PNS Drum Kit.SF2"
16 |
17 | private const val KEY = 60
18 | private const val VELOCITY = 127
19 |
20 | // Used to load the 'fluidsynth' library on application startup.
21 | // Check the CMakeLists.txt that is referenced in app/build.gradle,
22 | // within it there is the statement 'add_library' which specifies
23 | // this identifier.
24 | init {
25 | System.loadLibrary("fluidsynth")
26 | }
27 | }
28 |
29 | private val nativeLibJNI = NativeLibJNI()
30 |
31 | private lateinit var sf2file: File
32 |
33 | override fun onCreate(savedInstanceState: Bundle?) {
34 | super.onCreate(savedInstanceState)
35 | setContentView(R.layout.activity_main)
36 | sf2file = File(filesDir, SF2_FILE_NAME)
37 | copySF2IfNecessary() // sf2 file needs to be in internal directory, not assets
38 | nativeLibJNI.init(sf2file.absolutePath)
39 | sample_text.setOnTouchListener(this)
40 | sample_text.isEnabled = true
41 | }
42 |
43 | private fun copySF2IfNecessary() {
44 | if (sf2file.exists() && sf2file.length() > 0) return
45 | Okio.source(assets.open(SF2_FILE_NAME)).use { a ->
46 | Okio.buffer(Okio.sink(sf2file)).use { b ->
47 | b.writeAll(a)
48 | }
49 | }
50 | }
51 |
52 | private fun noteOn() {
53 | nativeLibJNI.noteOn(KEY, VELOCITY)
54 | }
55 |
56 | private fun noteOff() {
57 | nativeLibJNI.noteOff(KEY)
58 | }
59 |
60 | override fun onTouch(v: View?, event: MotionEvent?): Boolean {
61 | val action = event?.action
62 | when (action) {
63 | MotionEvent.ACTION_DOWN -> noteOn()
64 | MotionEvent.ACTION_UP -> noteOff()
65 | }
66 | return false
67 | }
68 |
69 | override fun onDestroy() {
70 | nativeLibJNI.destroy()
71 | super.onDestroy()
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/opensles/android/fluidsynth/fluidsynth_android_opensles/NativeLibJNI.kt:
--------------------------------------------------------------------------------
1 | package opensles.android.fluidsynth.fluidsynth_android_opensles
2 |
3 | class NativeLibJNI {
4 | external fun init(sf2path: String)
5 | external fun noteOn(key: Int, velocity: Int)
6 | external fun noteOff(key: Int)
7 | external fun programChange(channel: Int, programNumber: Int) : Boolean
8 | external fun destroy()
9 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | fluidsynth-android-opensles
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/opensles/android/fluidsynth/fluidsynth_android_opensles/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package opensles.android.fluidsynth.fluidsynth_android_opensles
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.2.30'
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.1'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/degill/fluidsynth-android-opensles/b7e28fed185bb31e3b606982c84a8831b5378c70/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Mar 09 14:39:40 CET 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------