├── .github └── workflows │ └── android-ci.yml ├── .gitignore ├── .travis.yml ├── ADLMIDI-Player ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── icon │ ├── big_icon_512.png │ ├── descr.png │ ├── descr.xcf │ ├── opl3_48.png │ └── oplplayer.png ├── proguard-rules.pro └── src │ ├── debug │ └── res │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ └── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ └── main │ ├── AndroidManifest.xml │ ├── cpp │ ├── CMakeLists.txt │ ├── adlmidi-jni.c │ ├── include │ │ └── adlmidi.h │ ├── libADLMIDIConfig.cmake.in │ ├── src │ │ ├── adlmidi.cpp │ │ ├── adlmidi_bankmap.h │ │ ├── adlmidi_bankmap.tcc │ │ ├── adlmidi_cvt.hpp │ │ ├── adlmidi_db.h │ │ ├── adlmidi_load.cpp │ │ ├── adlmidi_midiplay.cpp │ │ ├── adlmidi_midiplay.hpp │ │ ├── adlmidi_opl3.cpp │ │ ├── adlmidi_opl3.hpp │ │ ├── adlmidi_private.cpp │ │ ├── adlmidi_private.hpp │ │ ├── adlmidi_ptr.hpp │ │ ├── adlmidi_sequencer.cpp │ │ ├── chips │ │ │ ├── common │ │ │ │ ├── mutex.hpp │ │ │ │ └── ptr.hpp │ │ │ ├── dos_hw_opl.cpp │ │ │ ├── dos_hw_opl.h │ │ │ ├── dosbox │ │ │ │ ├── dbopl.cpp │ │ │ │ └── dbopl.h │ │ │ ├── dosbox_opl3.cpp │ │ │ ├── dosbox_opl3.h │ │ │ ├── esfmu │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── assets │ │ │ │ │ └── logo.png │ │ │ │ ├── esfm.c │ │ │ │ ├── esfm.h │ │ │ │ └── esfm_registers.c │ │ │ ├── esfmu_opl3.cpp │ │ │ ├── esfmu_opl3.h │ │ │ ├── java │ │ │ │ └── JavaOPL3.hpp │ │ │ ├── java_opl3.cpp │ │ │ ├── java_opl3.h │ │ │ ├── mame │ │ │ │ ├── mame_fmopl.cpp │ │ │ │ └── opl.h │ │ │ ├── mame_opl2.cpp │ │ │ ├── mame_opl2.h │ │ │ ├── nuked │ │ │ │ ├── LICENSE │ │ │ │ ├── nukedopl3.c │ │ │ │ ├── nukedopl3.h │ │ │ │ ├── nukedopl3_174.c │ │ │ │ └── nukedopl3_174.h │ │ │ ├── nuked_opl3.cpp │ │ │ ├── nuked_opl3.h │ │ │ ├── nuked_opl3_v174.cpp │ │ │ ├── nuked_opl3_v174.h │ │ │ ├── opal │ │ │ │ ├── LICENSE.txt │ │ │ │ ├── old │ │ │ │ │ ├── LICENSE.txt │ │ │ │ │ ├── README.old │ │ │ │ │ ├── opal-orig.hpp │ │ │ │ │ └── opal-pan.diff │ │ │ │ ├── opal.c │ │ │ │ └── opal.h │ │ │ ├── opal_opl3.cpp │ │ │ ├── opal_opl3.h │ │ │ ├── opl_chip_base.h │ │ │ ├── opl_chip_base.tcc │ │ │ ├── opl_serial_misc.h │ │ │ ├── opl_serial_port.cpp │ │ │ ├── opl_serial_port.h │ │ │ ├── ym3812_lle.cpp │ │ │ ├── ym3812_lle.h │ │ │ ├── ym3812_lle │ │ │ │ ├── nopl2.c │ │ │ │ ├── nopl2.h │ │ │ │ ├── nuked_fmopl2.c │ │ │ │ └── nuked_fmopl2.h │ │ │ ├── ymf262_lle.cpp │ │ │ ├── ymf262_lle.h │ │ │ ├── ymf262_lle │ │ │ │ ├── LICENSE │ │ │ │ ├── Readme.md │ │ │ │ ├── nopl3.c │ │ │ │ ├── nopl3.h │ │ │ │ ├── nuked_fmopl3.c │ │ │ │ └── nuked_fmopl3.h │ │ │ ├── ymfm │ │ │ │ ├── README.md │ │ │ │ ├── ymfm.h │ │ │ │ ├── ymfm_adpcm.cpp │ │ │ │ ├── ymfm_adpcm.h │ │ │ │ ├── ymfm_fm.h │ │ │ │ ├── ymfm_fm.ipp │ │ │ │ ├── ymfm_misc.cpp │ │ │ │ ├── ymfm_misc.h │ │ │ │ ├── ymfm_opl.cpp │ │ │ │ ├── ymfm_opl.h │ │ │ │ ├── ymfm_pcm.cpp │ │ │ │ ├── ymfm_pcm.h │ │ │ │ ├── ymfm_ssg.cpp │ │ │ │ └── ymfm_ssg.h │ │ │ ├── ymfm_opl2.cpp │ │ │ ├── ymfm_opl2.h │ │ │ ├── ymfm_opl3.cpp │ │ │ └── ymfm_opl3.h │ │ ├── cvt_mus2mid.hpp │ │ ├── cvt_xmi2mid.hpp │ │ ├── file_reader.hpp │ │ ├── fraction.hpp │ │ ├── inst_db.cpp │ │ ├── midi_sequencer.h │ │ ├── midi_sequencer.hpp │ │ ├── midi_sequencer_impl.hpp │ │ ├── oplinst.h │ │ ├── structures │ │ │ ├── pl_list.hpp │ │ │ └── pl_list.tcc │ │ └── wopl │ │ │ ├── wopl_file.c │ │ │ └── wopl_file.h │ └── update.sh │ ├── ic_launcher-playstore.png │ ├── ic_launcher-web.png │ ├── java │ └── ru │ │ └── wohlsoft │ │ └── adlmidiplayer │ │ ├── AppSettings.java │ │ ├── HardButtonReceiver.java │ │ ├── OpenFileDialog.java │ │ ├── Player.java │ │ └── PlayerService.java │ └── res │ ├── drawable-hdpi │ └── ic_music_playing.png │ ├── drawable-mdpi │ └── ic_music_playing.png │ ├── drawable-xhdpi │ └── ic_music_playing.png │ ├── drawable-xxhdpi │ └── ic_music_playing.png │ ├── drawable-xxxhdpi │ └── ic_music_playing.png │ ├── drawable │ ├── ic_menu_back.png │ └── ic_menu_home.png │ ├── layout │ └── activity_player.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── values-en │ └── strings.xml │ ├── values-fr │ └── strings.xml │ ├── values-ru │ └── strings.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── ic_launcher_background.xml │ ├── strings.xml │ └── styles.xml ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.github/workflows/android-ci.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - master 8 | - devel 9 | - versus-ci-android 10 | pull_request: 11 | branches: 12 | - main 13 | - master 14 | 15 | #defaults: 16 | # run: 17 | # working-directory: . 18 | 19 | jobs: 20 | build: 21 | runs-on: ubuntu-latest 22 | name: Build release-apk 23 | steps: 24 | - uses: styfle/cancel-workflow-action@0.12.1 25 | with: 26 | workflow_id: android-ci.yml 27 | all_but_latest: true 28 | access_token: ${{ github.token }} 29 | 30 | - uses: actions/checkout@v4 31 | 32 | # - uses: nelonoel/branch-name@v1.0.1 33 | - uses: Wohlstand/branch-name@v1.0.2-wohl 34 | 35 | - name: Pull submodules 36 | shell: bash 37 | run: | 38 | git submodule init 39 | git submodule update 40 | 41 | - name: Install Dependencies 42 | shell: bash 43 | run: | 44 | sudo apt-get update -qq 45 | sudo apt-get install -qq lftp 46 | 47 | - name: Set up JDK 17 48 | uses: actions/setup-java@v4.2.1 49 | with: 50 | java-version: 17 51 | distribution: 'temurin' 52 | 53 | - uses: nttld/setup-ndk@v1 54 | with: 55 | ndk-version: r23c 56 | # IMPORTANT NOTE: The SDK r23b is REQUIRED to support Android 4.1, 4.2, and 4.3, and to support non-Neon hardware 57 | 58 | - name: Setup Android SDK 59 | uses: android-actions/setup-android@v3 60 | 61 | - name: Output version code 62 | run: echo VERSION_CODE=${{ github.run_number }} > ./version.properties 63 | 64 | - name: Import the signing 65 | run: echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 -d > release-key.jks 66 | 67 | - name: Build with Gradle 68 | run: ./gradlew bundleReleaseci assembleReleaseci 69 | env: 70 | RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }} 71 | RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }} 72 | RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }} 73 | PIN_ALIAS: ${{ secrets.PIN_ALIAS }} 74 | DB_PASS_ALIAS: ${{ secrets.DB_PASS_ALIAS }} 75 | 76 | - name: Rename APK 77 | shell: bash 78 | run: | 79 | if [[ "${BRANCH_NAME}" == *"merge"* ]]; then 80 | BRANCH_NAME_RES="pull-request" 81 | echo "-- Pull-request detected!" 82 | else 83 | BRANCH_NAME_RES=${BRANCH_NAME} 84 | fi 85 | 86 | mv ADLMIDI-Player/build/outputs/apk/releaseci/ADLMIDI-Player-releaseci.apk ADLMIDI-Player-android-${BRANCH_NAME_RES}.apk 87 | mv ADLMIDI-Player/build/outputs/bundle/releaseci/ADLMIDI-Player-releaseci.aab ADLMIDI-Player-android-${BRANCH_NAME_RES}.aab 88 | 89 | - name: Upload APK 90 | if: success() 91 | uses: actions/upload-artifact@v4 92 | with: 93 | name: ADLMIDI-Player-android-APK 94 | path: ADLMIDI-Player-android-*.apk 95 | 96 | - name: Upload AAB 97 | if: success() 98 | uses: actions/upload-artifact@v4 99 | with: 100 | name: ADLMIDI-Player-android-AAB 101 | path: ADLMIDI-Player-android-*.aab 102 | 103 | - name: Deploy to builds.wohlsoft.ru 104 | if: success() && github.event_name != 'pull_request' 105 | shell: bash 106 | run: | 107 | if [[ "${BRANCH_NAME}" == *"merge"* ]]; then 108 | BRANCH_NAME_RES="pull-request" 109 | echo "-- Pull-request detected!" 110 | else 111 | BRANCH_NAME_RES=${BRANCH_NAME} 112 | fi 113 | 114 | UPLOAD_LIST="set ssl:verify-certificate no;" 115 | UPLOAD_LIST="${UPLOAD_LIST} put -O "www/android/" ./ADLMIDI-Player-android-${BRANCH_NAME_RES}.apk;" 116 | UPLOAD_LIST="${UPLOAD_LIST} put -O "www/android/" ./ADLMIDI-Player-android-${BRANCH_NAME_RES}.aab;" 117 | lftp -e "${UPLOAD_LIST} exit" -u ${{ secrets.builds_login }},${{ secrets.builds_password }} ${{ secrets.builds_host }} 118 | 119 | - name: List Build Directory 120 | if: always() 121 | shell: bash 122 | run: | 123 | git status 124 | ls -lR . 125 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/ 38 | 39 | # Keystore files 40 | *.jks 41 | /.idea/workspace.xml 42 | /.idea/libraries 43 | .DS_Store 44 | .externalNativeBuild 45 | 46 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | git: 2 | depth: 1 3 | 4 | branches: 5 | only: 6 | - master 7 | 8 | jdk: oraclejdk8 9 | language: android 10 | sudo: required 11 | env: 12 | global: 13 | - ANDROID_API_LEVEL=28 14 | - ANDROID_BUILD_TOOLS_VERSION=28.0.3 15 | - ANDROID_ABI=armeabi-v7a 16 | - ANDROID_TAG=google_apis 17 | - ANDROID_NDK_REVISION=r19 18 | - ADB_INSTALL_TIMEOUT=5 # minutes 19 | 20 | android: 21 | components: 22 | - platform-tools 23 | - tools 24 | - build-tools-$ANDROID_BUILD_TOOLS_VERSION 25 | - android-$ANDROID_API_LEVEL 26 | # Support library 27 | - extra-android-support 28 | # Latest artifacts in local repository 29 | - extra-google-m2repository 30 | - extra-android-m2repository 31 | # Specify at least one system image 32 | - sys-img-armeabi-v7a-android-$ANDROID_API_LEVEL 33 | - sys-img-x86_64-android-$ANDROID_API_LEVEL 34 | #- sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL 35 | #- sys-img-armeabi-v7a-android-$ANDROID_API_LEVEL 36 | #- sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL 37 | licenses: 38 | - android-sdk-preview-license.+ 39 | - android-sdk-license.+ 40 | - google-gdk-license-.+ 41 | - build-tools-.+ 42 | - cmake.+ 43 | 44 | before_install: 45 | # By default, we get an older version of libstdc++6 so we need to update it 46 | # http://askubuntu.com/questions/575505/glibcxx-3-4-20-not-found-how-to-fix-this-error 47 | - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y 48 | - sudo apt-get update 49 | - sudo apt-get install libstdc++6 50 | 51 | - mkdir "$ANDROID_HOME/licenses" || true 52 | - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license" 53 | - echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/google-gdk-license" 54 | - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license" 55 | 56 | # - echo y | android update sdk --no-ui --all --filter "tools" 57 | # - echo y | android update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS_VERSION},android-${ANDROID_API_LEVEL},extra-android-m2repository 58 | - wget https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_REVISION}-linux-x86_64.zip -O ndk.zip 59 | - unzip ndk.zip -d . > /dev/null 60 | - export ANDROID_NDK_HOME=`pwd`/android-ndk-${ANDROID_NDK_REVISION} 61 | - export PATH=${PATH}:${ANDROID_NDK_HOME} 62 | 63 | - wget https://github.com/Commit451/android-cmake-installer/releases/download/1.1.0/install-cmake.sh 64 | - chmod +x install-cmake.sh 65 | - bash ./install-cmake.sh 66 | 67 | - chmod +x gradlew 68 | - ./gradlew dependencies || true 69 | - ./gradlew assembleDebug 70 | 71 | # # Emulator Management: Create, Start and Wait 72 | # before_script: 73 | ##- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a --tag google_apis #--tag ${ANDROID_TAG} 74 | ##- echo y | android update sdk --all -u -t sys-img-armeabi-v7a-android-${ANDROID_API_LEVEL} 75 | # - echo y | android update sdk --all -u -t sys-img-x86_64-android-${ANDROID_API_LEVEL} 76 | # - android list targets 77 | # - echo no | android create avd --force -n test -t android-${ANDROID_API_LEVEL} --abi x86_64 78 | # - emulator -avd test -no-audio -no-window & 79 | # - android-wait-for-emulator 80 | # - adb shell input keyevent 82 & 81 | 82 | -------------------------------------------------------------------------------- /ADLMIDI-Player/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /release 3 | .cxx 4 | -------------------------------------------------------------------------------- /ADLMIDI-Player/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Sets the minimum version of CMake required to build the native 2 | # library. You should either keep the default value or only pass a 3 | # value of 3.4.0 or lower. 4 | 5 | cmake_minimum_required(VERSION 3.4.1) 6 | project(ADLMIDI_JniBind C CXX) 7 | 8 | # Creates and names a library, sets it as either STATIC 9 | # or SHARED, and provides the relative paths to its source code. 10 | # You can define multiple libraries, and CMake builds it for you. 11 | # Gradle automatically packages shared libraries with your APK. 12 | 13 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-omit-frame-pointer") 14 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-omit-frame-pointer") 15 | 16 | string(REGEX REPLACE "-O3" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") 17 | string(REGEX REPLACE "-O3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") 18 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os -fdata-sections -ffunction-sections") 19 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -fdata-sections -ffunction-sections") 20 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -funwind-tables") 21 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -funwind-tables") 22 | 23 | set(FILE_PATH_OVERRIDE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=/builds/fdroid/fdroiddata/build/ru.wohlsoft.adlmidiplayer/") 24 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${FILE_PATH_OVERRIDE}") 25 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${FILE_PATH_OVERRIDE}") 26 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${FILE_PATH_OVERRIDE}") 27 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${FILE_PATH_OVERRIDE}") 28 | set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${FILE_PATH_OVERRIDE}") 29 | set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${FILE_PATH_OVERRIDE}") 30 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=none") 31 | set(ENV{CFLAGS} "${FILE_PATH_OVERRIDE}") 32 | set(ENV{CXXFLAGS} "${FILE_PATH_OVERRIDE}") 33 | 34 | set(libADLMIDI_SHARED OFF) 35 | set(libADLMIDI_STATIC ON) 36 | set(WITH_CPP_EXTRAS OFF) 37 | set(WITH_MIDIPLAY OFF) 38 | set(WITH_VLC_PLUGIN OFF) 39 | set(WITH_OLD_UTILS OFF) 40 | set(EXAMPLE_SDL2_AUDIO OFF) 41 | add_subdirectory(${ADLMIDI_JniBind_SOURCE_DIR}/src/main/cpp) 42 | 43 | add_library(ADLMIDI_IF INTERFACE) 44 | target_link_libraries(ADLMIDI_IF INTERFACE ADLMIDI_static) 45 | 46 | add_library( 47 | # Sets the name of the library. 48 | adlmidi-jni 49 | 50 | # Sets the library as a shared library. 51 | SHARED 52 | 53 | # Provides a relative path to your source file(s). 54 | # Associated headers in the same location as their source 55 | # file are automatically included. 56 | src/main/cpp/adlmidi-jni.c 57 | ) 58 | 59 | target_link_libraries(adlmidi-jni ADLMIDI_IF) 60 | target_include_directories(adlmidi-jni PUBLIC src/main/cpp/include) 61 | add_dependencies(adlmidi-jni ADLMIDI_static) 62 | 63 | # Searches for a specified prebuilt library and stores the path as a 64 | # variable. Because system libraries are included in the search path by 65 | # default, you only need to specify the name of the public NDK library 66 | # you want to add. CMake verifies that the library exists before 67 | # completing its build. 68 | 69 | find_library( 70 | # Sets the name of the path variable. 71 | log-lib 72 | # Specifies the name of the NDK library that 73 | # you want CMake to locate. 74 | log 75 | ) 76 | 77 | # Specifies libraries CMake should link to your target library. You 78 | # can link multiple libraries, such as libraries you define in the 79 | # build script, prebuilt third-party libraries, or system libraries. 80 | 81 | target_link_libraries( 82 | # Specifies the target library. 83 | adlmidi-jni 84 | # Links the target library to the log library 85 | # included in the NDK. 86 | ${log-lib} 87 | OpenSLES 88 | ) 89 | 90 | # target_link_libraries( native-audio-jni android log OpenSLES) 91 | 92 | -------------------------------------------------------------------------------- /ADLMIDI-Player/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def release_store_password = System.env.RELEASE_STORE_PASSWORD 4 | def release_key_password = System.env.RELEASE_KEY_PASSWORD 5 | def release_key_alias = System.env.RELEASE_KEY_ALIAS 6 | def pin_alias = System.env.PIN_ALIAS 7 | def db_pass_alias = System.env.DB_PASS_ALIAS 8 | 9 | android { 10 | compileSdk 34 11 | 12 | // Note: The NDK 23 is SIGNIFICANTLY important, because of the support for non-NEON and older Android versions 13 | // The NDK 24 removes the support for Android 4.1, 4.2, and 4.3. 14 | // See details: https://github.com/android/ndk/wiki/Changelog-r24 15 | ndkVersion "23.2.8568313" 16 | 17 | defaultConfig { 18 | applicationId "ru.wohlsoft.adlmidiplayer" 19 | minSdkVersion 14 20 | targetSdkVersion 34 21 | versionCode 1050100 22 | versionName '1.5.1.0' 23 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 24 | externalNativeBuild { 25 | cmake { 26 | cppFlags "" 27 | } 28 | } 29 | ndk{ 30 | abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" 31 | // debugSymbolLevel 'SYMBOL_TABLE' 32 | } 33 | } 34 | 35 | signingConfigs { 36 | releaseci { 37 | storeFile file("../release-key.jks") 38 | storePassword = release_store_password 39 | keyAlias = release_key_alias 40 | keyPassword = release_key_password 41 | } 42 | } 43 | 44 | buildTypes { 45 | release { 46 | minifyEnabled false 47 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 48 | debuggable false 49 | jniDebuggable false 50 | renderscriptDebuggable false 51 | ndk { 52 | debugSymbolLevel = 'SYMBOL_TABLE' 53 | } 54 | } 55 | releaseci { 56 | minifyEnabled false 57 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 58 | buildConfigField "String", "PIN_ALIAS", "\"$pin_alias\"" 59 | buildConfigField "String", "DB_PASS_ALIAS", "\"$db_pass_alias\"" 60 | signingConfig signingConfigs.releaseci 61 | } 62 | debug { 63 | debuggable true 64 | jniDebuggable true 65 | renderscriptDebuggable false 66 | minifyEnabled false 67 | applicationIdSuffix '.debug' 68 | versionNameSuffix '-DEVDEBUG' 69 | } 70 | } 71 | 72 | externalNativeBuild { 73 | cmake { 74 | path "CMakeLists.txt" 75 | } 76 | } 77 | productFlavors { 78 | } 79 | lint { 80 | abortOnError false 81 | checkReleaseBuilds false 82 | } 83 | namespace 'ru.wohlsoft.adlmidiplayer' 84 | } 85 | 86 | dependencies { 87 | implementation fileTree(include: ['*.jar'], dir: 'libs') 88 | implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0' 89 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { 90 | exclude group: 'com.android.support', module: 'support-annotations' 91 | }) 92 | //noinspection GradleDependency: Last version that supports MinSDK 14 93 | implementation 'androidx.appcompat:appcompat:1.6.1' 94 | compileOnly 'junit:junit:4.13.2' 95 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 96 | } 97 | -------------------------------------------------------------------------------- /ADLMIDI-Player/icon/big_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/icon/big_icon_512.png -------------------------------------------------------------------------------- /ADLMIDI-Player/icon/descr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/icon/descr.png -------------------------------------------------------------------------------- /ADLMIDI-Player/icon/descr.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/icon/descr.xcf -------------------------------------------------------------------------------- /ADLMIDI-Player/icon/opl3_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/icon/opl3_48.png -------------------------------------------------------------------------------- /ADLMIDI-Player/icon/oplplayer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/icon/oplplayer.png -------------------------------------------------------------------------------- /ADLMIDI-Player/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/vitaly/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -optimizationpasses 5 19 | -dontpreverify 20 | -repackageclasses '' 21 | -allowaccessmodification 22 | -optimizations !code/simplification/arithmetic 23 | -keepattributes LineNumberTable,SourceFile,*Annotation* 24 | 25 | -verbose 26 | 27 | -dump obfuscation/class_files.txt 28 | -printseeds obfuscation/seeds.txt 29 | -printusage obfuscation/unused.txt 30 | -printmapping obfuscation/mapping.txt 31 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/libADLMIDIConfig.cmake.in: -------------------------------------------------------------------------------- 1 | include(FeatureSummary) 2 | set_package_properties(libADLMIDI PROPERTIES 3 | URL "https://github.com/Wohlstand/libADLMIDI" 4 | DESCRIPTION "libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation" 5 | ) 6 | 7 | @PACKAGE_INIT@ 8 | 9 | if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/libADLMIDI-shared-targets.cmake") 10 | include("${CMAKE_CURRENT_LIST_DIR}/libADLMIDI-shared-targets.cmake") 11 | endif() 12 | if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/libADLMIDI-static-targets.cmake") 13 | include("${CMAKE_CURRENT_LIST_DIR}/libADLMIDI-static-targets.cmake") 14 | endif() 15 | 16 | if(TARGET libADLMIDI::ADLMIDI_shared) 17 | if(CMAKE_VERSION VERSION_LESS "3.18") 18 | add_library(libADLMIDI::ADLMIDI INTERFACE IMPORTED) 19 | set_target_properties(libADLMIDI::ADLMIDI PROPERTIES INTERFACE_LINK_LIBRARIES "libADLMIDI::ADLMIDI_shared") 20 | else() 21 | add_library(libADLMIDI::ADLMIDI ALIAS libADLMIDI::ADLMIDI_shared) 22 | endif() 23 | else() 24 | if(CMAKE_VERSION VERSION_LESS "3.18") 25 | add_library(libADLMIDI::ADLMIDI INTERFACE IMPORTED) 26 | set_target_properties(libADLMIDI::ADLMIDI PROPERTIES INTERFACE_LINK_LIBRARIES "libADLMIDI::ADLMIDI_static") 27 | else() 28 | add_library(libADLMIDI::ADLMIDI ALIAS libADLMIDI::ADLMIDI_static) 29 | endif() 30 | endif() 31 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/adlmidi_bankmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation 3 | * 4 | * Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma 5 | * ADLMIDI Library API: Copyright (c) 2015-2025 Vitaly Novichkov 6 | * 7 | * Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation: 8 | * http://iki.fi/bisqwit/source/adlmidi.html 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | #ifndef ADLMIDI_BANKMAP_H 25 | #define ADLMIDI_BANKMAP_H 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "adlmidi_ptr.hpp" 33 | 34 | /** 35 | * A simple hash map which accepts bank numbers as keys, can be reserved to a 36 | * fixed size, offers O(1) search and insertion, has a hash function to 37 | * optimize for the worst case, and has some good cache locality properties. 38 | */ 39 | template 40 | class BasicBankMap 41 | { 42 | public: 43 | typedef size_t key_type; /* the bank identifier */ 44 | typedef T mapped_type; 45 | typedef std::pair value_type; 46 | 47 | BasicBankMap(); 48 | void reserve(size_t capacity); 49 | 50 | size_t size() const 51 | { return m_size; } 52 | size_t capacity() const 53 | { return m_capacity; } 54 | bool empty() const 55 | { return m_size == 0; } 56 | 57 | class iterator; 58 | iterator begin() const; 59 | iterator end() const; 60 | 61 | struct do_not_expand_t {}; 62 | 63 | iterator find(key_type key); 64 | void erase(iterator it); 65 | std::pair insert(const value_type &value); 66 | std::pair insert(const value_type &value, do_not_expand_t); 67 | void clear(); 68 | 69 | T &operator[](key_type key); 70 | 71 | private: 72 | struct Slot; 73 | enum { minimum_allocation = 4 }; 74 | enum 75 | { 76 | hash_bits = 8, /* worst case # of collisions: 128^2/2^hash_bits */ 77 | hash_buckets = 1 << hash_bits 78 | }; 79 | 80 | public: 81 | class iterator 82 | { 83 | public: 84 | iterator(); 85 | value_type &operator*() const { return slot->value; } 86 | value_type *operator->() const { return &slot->value; } 87 | iterator &operator++(); 88 | bool operator==(const iterator &o) const; 89 | bool operator!=(const iterator &o) const; 90 | void to_ptrs(void *ptrs[3]); 91 | static iterator from_ptrs(void *const ptrs[3]); 92 | private: 93 | Slot **buckets; 94 | Slot *slot; 95 | size_t index; 96 | iterator(Slot **buckets, Slot *slot, size_t index); 97 | #ifdef _MSC_VER 98 | template 99 | friend class BasicBankMap; 100 | #else 101 | friend class BasicBankMap; 102 | #endif 103 | }; 104 | 105 | private: 106 | struct Slot { 107 | Slot *next, *prev; 108 | value_type value; 109 | Slot() : next(NULL), prev(NULL) {} 110 | }; 111 | AdlMIDI_SPtrArray m_buckets; 112 | std::list< AdlMIDI_SPtrArray > m_allocations; 113 | Slot *m_freeslots; 114 | size_t m_size; 115 | size_t m_capacity; 116 | static size_t hash(key_type key); 117 | Slot *allocate_slot(); 118 | Slot *ensure_allocate_slot(); 119 | void free_slot(Slot *slot); 120 | Slot *bucket_find(size_t index, key_type key); 121 | void bucket_add(size_t index, Slot *slot); 122 | void bucket_remove(size_t index, Slot *slot); 123 | }; 124 | 125 | #include "adlmidi_bankmap.tcc" 126 | 127 | #endif // ADLMIDI_BANKMAP_H 128 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/adlmidi_cvt.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation 3 | * 4 | * Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma 5 | * ADLMIDI Library API: Copyright (c) 2015-2025 Vitaly Novichkov 6 | * 7 | * Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation: 8 | * http://iki.fi/bisqwit/source/adlmidi.html 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | #include "oplinst.h" 25 | #include "wopl/wopl_file.h" 26 | #include 27 | 28 | template 29 | static void cvt_generic_to_FMIns(OplInstMeta &ins, const WOPLI &in) 30 | { 31 | ins.voice2_fine_tune = 0.0; 32 | int voice2_fine_tune = in.second_voice_detune; 33 | 34 | if(voice2_fine_tune != 0) 35 | { 36 | // Simulate behavior of DMX second voice detune 37 | ins.voice2_fine_tune = (double)(((voice2_fine_tune + 128) >> 1) - 64) / 32.0; 38 | } 39 | 40 | ins.midiVelocityOffset = in.midi_velocity_offset; 41 | ins.drumTone = in.percussion_key_number; 42 | ins.flags = (in.inst_flags & WOPL_Ins_4op) && (in.inst_flags & WOPL_Ins_Pseudo4op) ? OplInstMeta::Flag_Pseudo4op : 0; 43 | ins.flags|= (in.inst_flags & WOPL_Ins_4op) && ((in.inst_flags & WOPL_Ins_Pseudo4op) == 0) ? OplInstMeta::Flag_Real4op : 0; 44 | ins.flags|= (in.inst_flags & WOPL_Ins_IsBlank) ? OplInstMeta::Flag_NoSound : 0; 45 | ins.flags|= in.inst_flags & WOPL_RhythmModeMask; 46 | 47 | for(size_t op = 0, slt = 0; op < 4; op++, slt++) 48 | { 49 | ins.op[slt].carrier_E862 = 50 | ((static_cast(in.operators[op].waveform_E0) << 24) & 0xFF000000) //WaveForm 51 | | ((static_cast(in.operators[op].susrel_80) << 16) & 0x00FF0000) //SusRel 52 | | ((static_cast(in.operators[op].atdec_60) << 8) & 0x0000FF00) //AtDec 53 | | ((static_cast(in.operators[op].avekf_20) << 0) & 0x000000FF); //AVEKM 54 | ins.op[slt].carrier_40 = in.operators[op].ksl_l_40;//KSLL 55 | 56 | op++; 57 | ins.op[slt].modulator_E862 = 58 | ((static_cast(in.operators[op].waveform_E0) << 24) & 0xFF000000) //WaveForm 59 | | ((static_cast(in.operators[op].susrel_80) << 16) & 0x00FF0000) //SusRel 60 | | ((static_cast(in.operators[op].atdec_60) << 8) & 0x0000FF00) //AtDec 61 | | ((static_cast(in.operators[op].avekf_20) << 0) & 0x000000FF); //AVEKM 62 | ins.op[slt].modulator_40 = in.operators[op].ksl_l_40;//KSLL 63 | } 64 | 65 | ins.op[0].noteOffset = static_cast(in.note_offset1); 66 | ins.op[0].feedconn = in.fb_conn1_C0; 67 | ins.op[1].noteOffset = static_cast(in.note_offset2); 68 | ins.op[1].feedconn = in.fb_conn2_C0; 69 | 70 | ins.soundKeyOnMs = in.delay_on_ms; 71 | ins.soundKeyOffMs = in.delay_off_ms; 72 | } 73 | 74 | template 75 | static void cvt_FMIns_to_generic(WOPLI &ins, const OplInstMeta &in) 76 | { 77 | ins.second_voice_detune = 0; 78 | double voice2_fine_tune = in.voice2_fine_tune; 79 | if(voice2_fine_tune != 0) 80 | { 81 | int m = (int)(voice2_fine_tune * 32.0); 82 | m += 64; 83 | m <<= 1; 84 | m -= 128; 85 | ins.second_voice_detune = (uint8_t)m; 86 | } 87 | 88 | ins.midi_velocity_offset = in.midiVelocityOffset; 89 | ins.percussion_key_number = in.drumTone; 90 | ins.inst_flags = (in.flags & (OplInstMeta::Flag_Pseudo4op|OplInstMeta::Flag_Real4op)) ? WOPL_Ins_4op : 0; 91 | ins.inst_flags|= (in.flags & OplInstMeta::Flag_Pseudo4op) ? WOPL_Ins_Pseudo4op : 0; 92 | ins.inst_flags|= (in.flags & OplInstMeta::Flag_NoSound) ? WOPL_Ins_IsBlank : 0; 93 | ins.inst_flags |= in.flags & OplInstMeta::Mask_RhythmMode; 94 | 95 | for(size_t op = 0; op < 4; op++) 96 | { 97 | const OplTimbre &in2op = in.op[(op < 2) ? 0 : 1]; 98 | uint32_t regE862 = ((op & 1) == 0) ? in2op.carrier_E862 : in2op.modulator_E862; 99 | uint8_t reg40 = ((op & 1) == 0) ? in2op.carrier_40 : in2op.modulator_40; 100 | 101 | ins.operators[op].waveform_E0 = static_cast(regE862 >> 24); 102 | ins.operators[op].susrel_80 = static_cast(regE862 >> 16); 103 | ins.operators[op].atdec_60 = static_cast(regE862 >> 8); 104 | ins.operators[op].avekf_20 = static_cast(regE862 >> 0); 105 | ins.operators[op].ksl_l_40 = reg40; 106 | } 107 | 108 | ins.note_offset1 = in.op[0].noteOffset; 109 | ins.fb_conn1_C0 = in.op[0].feedconn; 110 | ins.note_offset2 = in.op[1].noteOffset; 111 | ins.fb_conn2_C0 = in.op[1].feedconn; 112 | 113 | ins.delay_on_ms = in.soundKeyOnMs; 114 | ins.delay_off_ms = in.soundKeyOffMs; 115 | } 116 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/adlmidi_db.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation 3 | * 4 | * Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma 5 | * ADLMIDI Library API: Copyright (c) 2015-2025 Vitaly Novichkov 6 | * 7 | * Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation: 8 | * http://iki.fi/bisqwit/source/adlmidi.html 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | 25 | #ifndef ADLDATA_DB_H 26 | #define ADLDATA_DB_H 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #if !defined(_MSC_VER) && !defined(__aarch64__) && !defined(__3DS__) 35 | #define ATTRIB_PACKED __attribute__((__packed__)) 36 | #else 37 | #define ATTRIB_PACKED 38 | #endif 39 | 40 | typedef uint16_t bank_count_t; 41 | typedef int16_t midi_bank_idx_t; 42 | 43 | #ifndef DISABLE_EMBEDDED_BANKS 44 | extern const size_t g_embeddedBanksCount; 45 | #endif 46 | 47 | namespace BanksDump 48 | { 49 | 50 | struct BankEntry 51 | { 52 | uint16_t bankSetup; 53 | bank_count_t banksMelodicCount; 54 | bank_count_t banksPercussionCount; 55 | const char *title; 56 | bank_count_t banksOffsetMelodic; 57 | bank_count_t banksOffsetPercussive; 58 | } ATTRIB_PACKED; 59 | 60 | struct MidiBank 61 | { 62 | uint8_t msb; 63 | uint8_t lsb; 64 | midi_bank_idx_t insts[128]; 65 | } ATTRIB_PACKED; 66 | 67 | struct InstrumentEntry 68 | { 69 | int16_t noteOffset1; 70 | int16_t noteOffset2; 71 | int8_t midiVelocityOffset; 72 | uint8_t percussionKeyNumber; 73 | uint8_t instFlags; 74 | int8_t secondVoiceDetune; 75 | uint16_t fbConn; 76 | uint16_t delay_on_ms; 77 | uint16_t delay_off_ms; 78 | int16_t ops[4]; 79 | } ATTRIB_PACKED; 80 | 81 | struct Operator 82 | { 83 | uint32_t d_E862; 84 | uint8_t d_40; 85 | } ATTRIB_PACKED; 86 | 87 | } /* namespace BanksDump */ 88 | 89 | #ifndef DISABLE_EMBEDDED_BANKS 90 | extern const char* const g_embeddedBankNames[]; 91 | extern const BanksDump::BankEntry g_embeddedBanks[]; 92 | extern const size_t g_embeddedBanksMidiIndex[]; 93 | extern const BanksDump::MidiBank g_embeddedBanksMidi[]; 94 | extern const BanksDump::InstrumentEntry g_embeddedBanksInstruments[]; 95 | extern const BanksDump::Operator g_embeddedBanksOperators[]; 96 | #endif 97 | 98 | #endif // ADLDATA_DB_H 99 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/adlmidi_private.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation 3 | * 4 | * Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma 5 | * ADLMIDI Library API: Copyright (c) 2015-2025 Vitaly Novichkov 6 | * 7 | * Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation: 8 | * http://iki.fi/bisqwit/source/adlmidi.html 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | #include "adlmidi_midiplay.hpp" 25 | #include "adlmidi_opl3.hpp" 26 | #include "adlmidi_private.hpp" 27 | #include "wopl/wopl_file.h" 28 | 29 | 30 | std::string ADLMIDI_ErrorString; 31 | 32 | // Generator callback on audio rate ticks 33 | 34 | #if defined(ADLMIDI_AUDIO_TICK_HANDLER) 35 | void adl_audioTickHandler(void *instance, uint32_t chipId, uint32_t rate) 36 | { 37 | reinterpret_cast(instance)->AudioTick(chipId, rate); 38 | } 39 | #endif 40 | 41 | int adlCalculateFourOpChannels(MIDIplay *play, bool silent) 42 | { 43 | Synth &synth = *play->m_synth; 44 | size_t n_fourop[2] = {0, 0}, n_total[2] = {0, 0}; 45 | bool rhythmModeNeeded = false; 46 | size_t numFourOps = 0; 47 | 48 | //Automatically calculate how much 4-operator channels is necessary 49 | { 50 | //For custom bank 51 | Synth::BankMap::iterator it = synth.m_insBanks.begin(); 52 | Synth::BankMap::iterator end = synth.m_insBanks.end(); 53 | for(; it != end; ++it) 54 | { 55 | size_t bank = it->first; 56 | size_t div = (bank & Synth::PercussionTag) ? 1 : 0; 57 | for(size_t i = 0; i < 128; ++i) 58 | { 59 | OplInstMeta &ins = it->second.ins[i]; 60 | if(ins.flags & OplInstMeta::Flag_NoSound) 61 | continue; 62 | if((ins.flags & OplInstMeta::Flag_Real4op) != 0) 63 | ++n_fourop[div]; 64 | ++n_total[div]; 65 | if(div && ((ins.flags & OplInstMeta::Mask_RhythmMode) != 0)) 66 | rhythmModeNeeded = true; 67 | } 68 | } 69 | } 70 | 71 | // All 2ops (no 4ops) 72 | if((n_fourop[0] == 0) && (n_fourop[1] == 0)) 73 | numFourOps = 0; 74 | // All 2op melodics and Some (or All) 4op drums 75 | else if((n_fourop[0] == 0) && (n_fourop[1] > 0)) 76 | numFourOps = 2; 77 | // Many 4op melodics 78 | else if((n_fourop[0] >= (n_total[0] * 7) / 8)) 79 | numFourOps = 6; 80 | // Few 4op melodics 81 | else if(n_fourop[0] > 0) 82 | numFourOps = 4; 83 | 84 | synth.m_numFourOps = static_cast(numFourOps * synth.m_numChips); 85 | 86 | // Update channel categories and set up four-operator channels 87 | if(!silent) 88 | synth.updateChannelCategories(); 89 | 90 | // Set rhythm mode when it needed 91 | synth.m_rhythmMode = rhythmModeNeeded; 92 | 93 | return 0; 94 | } 95 | 96 | #ifndef DISABLE_EMBEDDED_BANKS 97 | void adlFromInstrument(const BanksDump::InstrumentEntry &instIn, OplInstMeta &instOut) 98 | { 99 | instOut.voice2_fine_tune = 0.0; 100 | if(instIn.secondVoiceDetune != 0) 101 | instOut.voice2_fine_tune = (double)((((int)instIn.secondVoiceDetune + 128) >> 1) - 64) / 32.0; 102 | 103 | instOut.midiVelocityOffset = instIn.midiVelocityOffset; 104 | instOut.drumTone = instIn.percussionKeyNumber; 105 | instOut.flags = (instIn.instFlags & WOPL_Ins_4op) && (instIn.instFlags & WOPL_Ins_Pseudo4op) ? OplInstMeta::Flag_Pseudo4op : 0; 106 | instOut.flags|= (instIn.instFlags & WOPL_Ins_4op) && ((instIn.instFlags & WOPL_Ins_Pseudo4op) == 0) ? OplInstMeta::Flag_Real4op : 0; 107 | instOut.flags|= (instIn.instFlags & WOPL_Ins_IsBlank) ? OplInstMeta::Flag_NoSound : 0; 108 | instOut.flags|= instIn.instFlags & WOPL_RhythmModeMask; 109 | 110 | for(size_t op = 0; op < 2; op++) 111 | { 112 | if((instIn.ops[(op * 2) + 0] < 0) || (instIn.ops[(op * 2) + 1] < 0)) 113 | break; 114 | const BanksDump::Operator &op1 = g_embeddedBanksOperators[instIn.ops[(op * 2) + 0]]; 115 | const BanksDump::Operator &op2 = g_embeddedBanksOperators[instIn.ops[(op * 2) + 1]]; 116 | instOut.op[op].modulator_E862 = op1.d_E862; 117 | instOut.op[op].modulator_40 = op1.d_40; 118 | instOut.op[op].carrier_E862 = op2.d_E862; 119 | instOut.op[op].carrier_40 = op2.d_40; 120 | instOut.op[op].feedconn = (instIn.fbConn >> (op * 8)) & 0xFF; 121 | instOut.op[op].noteOffset = static_cast(op == 0 ? instIn.noteOffset1 : instIn.noteOffset2); 122 | } 123 | 124 | instOut.soundKeyOnMs = instIn.delay_on_ms; 125 | instOut.soundKeyOffMs = instIn.delay_off_ms; 126 | } 127 | #endif 128 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/adlmidi_ptr.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation 3 | * 4 | * Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma 5 | * ADLMIDI Library API: Copyright (c) 2015-2025 Vitaly Novichkov 6 | * 7 | * Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation: 8 | * http://iki.fi/bisqwit/source/adlmidi.html 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | #ifndef ADLMIDI_PTR_HPP_THING 25 | #define ADLMIDI_PTR_HPP_THING 26 | 27 | #include // swap 28 | #include 29 | #include 30 | 31 | /* 32 | Generic deleters for smart pointers 33 | */ 34 | template 35 | struct ADLMIDI_DefaultDelete 36 | { 37 | void operator()(T *x) { delete x; } 38 | }; 39 | template 40 | struct ADLMIDI_DefaultArrayDelete 41 | { 42 | void operator()(T *x) { delete[] x; } 43 | }; 44 | struct ADLMIDI_CDelete 45 | { 46 | void operator()(void *x) { free(x); } 47 | }; 48 | 49 | /* 50 | Safe unique pointer for C++98, non-copyable but swappable. 51 | */ 52 | template< class T, class Deleter = ADLMIDI_DefaultDelete > 53 | class AdlMIDI_UPtr 54 | { 55 | T *m_p; 56 | public: 57 | explicit AdlMIDI_UPtr(T *p = NULL) 58 | : m_p(p) {} 59 | ~AdlMIDI_UPtr() 60 | { 61 | reset(); 62 | } 63 | 64 | void reset(T *p = NULL) 65 | { 66 | if(p != m_p) { 67 | if(m_p) { 68 | Deleter del; 69 | del(m_p); 70 | } 71 | m_p = p; 72 | } 73 | } 74 | 75 | void swap(AdlMIDI_UPtr &other) 76 | { 77 | std::swap(m_p, other.m_p); 78 | } 79 | 80 | T *get() const 81 | { 82 | return m_p; 83 | } 84 | T &operator*() const 85 | { 86 | return *m_p; 87 | } 88 | T *operator->() const 89 | { 90 | return m_p; 91 | } 92 | T &operator[](size_t index) const 93 | { 94 | return m_p[index]; 95 | } 96 | private: 97 | AdlMIDI_UPtr(const AdlMIDI_UPtr &); 98 | AdlMIDI_UPtr &operator=(const AdlMIDI_UPtr &); 99 | }; 100 | 101 | template 102 | void swap(AdlMIDI_UPtr &a, AdlMIDI_UPtr &b) 103 | { 104 | a.swap(b); 105 | } 106 | 107 | /** 108 | Unique pointer for arrays. 109 | */ 110 | template 111 | class AdlMIDI_UPtrArray : 112 | public AdlMIDI_UPtr< T, ADLMIDI_DefaultArrayDelete > 113 | { 114 | public: 115 | explicit AdlMIDI_UPtrArray(T *p = NULL) 116 | : AdlMIDI_UPtr< T, ADLMIDI_DefaultArrayDelete >(p) {} 117 | }; 118 | 119 | /** 120 | Unique pointer for C memory. 121 | */ 122 | template 123 | class AdlMIDI_CPtr : 124 | public AdlMIDI_UPtr< T, ADLMIDI_CDelete > 125 | { 126 | public: 127 | explicit AdlMIDI_CPtr(T *p = NULL) 128 | : AdlMIDI_UPtr< T, ADLMIDI_CDelete >(p) {} 129 | }; 130 | 131 | /* 132 | Shared pointer with non-atomic counter 133 | FAQ: Why not std::shared_ptr? Because of Android NDK now doesn't supports it 134 | */ 135 | template< class T, class Deleter = ADLMIDI_DefaultDelete > 136 | class AdlMIDI_SPtr 137 | { 138 | T *m_p; 139 | size_t *m_counter; 140 | public: 141 | explicit AdlMIDI_SPtr(T *p = NULL) 142 | : m_p(p), m_counter(p ? new size_t(1) : NULL) {} 143 | ~AdlMIDI_SPtr() 144 | { 145 | reset(NULL); 146 | } 147 | 148 | AdlMIDI_SPtr(const AdlMIDI_SPtr &other) 149 | : m_p(other.m_p), m_counter(other.m_counter) 150 | { 151 | if(m_counter) 152 | ++*m_counter; 153 | } 154 | 155 | AdlMIDI_SPtr &operator=(const AdlMIDI_SPtr &other) 156 | { 157 | if(this == &other) 158 | return *this; 159 | reset(); 160 | m_p = other.m_p; 161 | m_counter = other.m_counter; 162 | if(m_counter) 163 | ++*m_counter; 164 | return *this; 165 | } 166 | 167 | void reset(T *p = NULL) 168 | { 169 | if(p != m_p) { 170 | if(m_p && --*m_counter == 0) { 171 | Deleter del; 172 | del(m_p); 173 | if(!p) { 174 | delete m_counter; 175 | m_counter = NULL; 176 | } 177 | } 178 | m_p = p; 179 | if(p) { 180 | if(!m_counter) 181 | m_counter = new size_t; 182 | *m_counter = 1; 183 | } 184 | } 185 | } 186 | 187 | T *get() const 188 | { 189 | return m_p; 190 | } 191 | T &operator*() const 192 | { 193 | return *m_p; 194 | } 195 | T *operator->() const 196 | { 197 | return m_p; 198 | } 199 | T &operator[](size_t index) const 200 | { 201 | return m_p[index]; 202 | } 203 | }; 204 | 205 | /** 206 | Shared pointer for arrays. 207 | */ 208 | template 209 | class AdlMIDI_SPtrArray : 210 | public AdlMIDI_SPtr< T, ADLMIDI_DefaultArrayDelete > 211 | { 212 | public: 213 | explicit AdlMIDI_SPtrArray(T *p = NULL) 214 | : AdlMIDI_SPtr< T, ADLMIDI_DefaultArrayDelete >(p) {} 215 | }; 216 | 217 | #endif //ADLMIDI_PTR_HPP_THING 218 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/common/mutex.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation 3 | * 4 | * Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma 5 | * ADLMIDI Library API: Copyright (c) 2015-2025 Vitaly Novichkov 6 | * 7 | * Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation: 8 | * http://iki.fi/bisqwit/source/adlmidi.html 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | #ifndef DOSBOX_NO_MUTEX 25 | # if defined(USE_LIBOGC_MUTEX) 26 | # include 27 | typedef mutex_t MutexNativeObject; 28 | # elif defined(USE_WUT_MUTEX) 29 | # if __cplusplus < 201103L || (defined(_MSC_VER) && _MSC_VER < 1900) 30 | # define static_assert(x, y) 31 | # endif 32 | # include 33 | typedef OSMutex MutexNativeObject; 34 | # elif !defined(_WIN32) 35 | # include 36 | typedef pthread_mutex_t MutexNativeObject; 37 | # else 38 | # include 39 | typedef CRITICAL_SECTION MutexNativeObject; 40 | # endif 41 | #endif 42 | 43 | 44 | class Mutex 45 | { 46 | public: 47 | Mutex(); 48 | ~Mutex(); 49 | void lock(); 50 | void unlock(); 51 | private: 52 | #if !defined(DOSBOX_NO_MUTEX) 53 | MutexNativeObject m; 54 | #endif 55 | Mutex(const Mutex &); 56 | Mutex &operator=(const Mutex &); 57 | }; 58 | 59 | class MutexHolder 60 | { 61 | public: 62 | explicit MutexHolder(Mutex &m) : m(m) { m.lock(); } 63 | ~MutexHolder() { m.unlock(); } 64 | private: 65 | Mutex &m; 66 | MutexHolder(const MutexHolder &); 67 | MutexHolder &operator=(const MutexHolder &); 68 | }; 69 | 70 | #if defined(DOSBOX_NO_MUTEX) // No mutex, just a dummy 71 | 72 | inline Mutex::Mutex() 73 | {} 74 | 75 | inline Mutex::~Mutex() 76 | {} 77 | 78 | inline void Mutex::lock() 79 | {} 80 | 81 | inline void Mutex::unlock() 82 | {} 83 | 84 | #elif defined(USE_WUT_MUTEX) 85 | 86 | inline Mutex::Mutex() 87 | { 88 | OSInitMutex(&m); 89 | } 90 | 91 | inline Mutex::~Mutex() 92 | {} 93 | 94 | inline void Mutex::lock() 95 | { 96 | OSLockMutex(&m); 97 | } 98 | 99 | inline void Mutex::unlock() 100 | { 101 | OSUnlockMutex(&m); 102 | } 103 | 104 | #elif defined(USE_LIBOGC_MUTEX) 105 | 106 | inline Mutex::Mutex() 107 | { 108 | m = LWP_MUTEX_NULL; 109 | LWP_MutexInit(&m, 0); 110 | } 111 | 112 | inline Mutex::~Mutex() 113 | { 114 | LWP_MutexDestroy(m); 115 | } 116 | 117 | inline void Mutex::lock() 118 | { 119 | LWP_MutexLock(m); 120 | } 121 | 122 | inline void Mutex::unlock() 123 | { 124 | LWP_MutexUnlock(m); 125 | } 126 | 127 | #elif !defined(_WIN32) // pthread 128 | 129 | inline Mutex::Mutex() 130 | { 131 | pthread_mutex_init(&m, NULL); 132 | } 133 | 134 | inline Mutex::~Mutex() 135 | { 136 | pthread_mutex_destroy(&m); 137 | } 138 | 139 | inline void Mutex::lock() 140 | { 141 | pthread_mutex_lock(&m); 142 | } 143 | 144 | inline void Mutex::unlock() 145 | { 146 | pthread_mutex_unlock(&m); 147 | } 148 | 149 | #else // Win32 150 | 151 | inline Mutex::Mutex() 152 | { 153 | InitializeCriticalSection(&m); 154 | } 155 | 156 | inline Mutex::~Mutex() 157 | { 158 | DeleteCriticalSection(&m); 159 | } 160 | 161 | inline void Mutex::lock() 162 | { 163 | EnterCriticalSection(&m); 164 | } 165 | 166 | inline void Mutex::unlock() 167 | { 168 | LeaveCriticalSection(&m); 169 | } 170 | #endif 171 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/common/ptr.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation 3 | * 4 | * Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma 5 | * ADLMIDI Library API: Copyright (c) 2015-2025 Vitaly Novichkov 6 | * 7 | * Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation: 8 | * http://iki.fi/bisqwit/source/adlmidi.html 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | #ifndef MY_PTR_HPP_THING 25 | #define MY_PTR_HPP_THING 26 | 27 | #include 28 | #include 29 | 30 | /* 31 | Generic deleters for smart pointers 32 | */ 33 | template 34 | struct My_DefaultDelete 35 | { 36 | void operator()(T *x) { delete x; } 37 | }; 38 | 39 | template 40 | struct My_DefaultArrayDelete 41 | { 42 | void operator()(T *x) { delete[] x; } 43 | }; 44 | 45 | struct My_CDelete 46 | { 47 | void operator()(void *x) { free(x); } 48 | }; 49 | 50 | /* 51 | Safe unique pointer for C++98, non-copyable but swappable. 52 | */ 53 | template< class T, class Deleter = My_DefaultDelete > 54 | class My_UPtr 55 | { 56 | T *m_p; 57 | public: 58 | explicit My_UPtr(T *p = NULL) 59 | : m_p(p) {} 60 | ~My_UPtr() 61 | { 62 | reset(); 63 | } 64 | 65 | void reset(T *p = NULL) 66 | { 67 | if(p != m_p) 68 | { 69 | if(m_p) 70 | { 71 | Deleter del; 72 | del(m_p); 73 | } 74 | m_p = p; 75 | } 76 | } 77 | 78 | T *get() const 79 | { 80 | return m_p; 81 | } 82 | 83 | T *release() 84 | { 85 | T *ret = m_p; 86 | m_p = NULL; 87 | return ret; 88 | } 89 | 90 | T &operator*() const 91 | { 92 | return *m_p; 93 | } 94 | 95 | T *operator->() const 96 | { 97 | return m_p; 98 | } 99 | 100 | T &operator[](size_t index) const 101 | { 102 | return m_p[index]; 103 | } 104 | 105 | private: 106 | My_UPtr(const My_UPtr &); 107 | My_UPtr &operator=(const My_UPtr &); 108 | }; 109 | 110 | #endif // MY_PTR_HPP_THING 111 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/dos_hw_opl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #ifdef __DJGPP__ 26 | # include 27 | #endif 28 | 29 | #include "dos_hw_opl.h" 30 | 31 | static uint16_t s_OPLBase[2] = {0x388, 0x38A}; 32 | static char s_devName[80] = {0}; 33 | static OPLChipBase::ChipType s_type = OPLChipBase::CHIPTYPE_OPL3; 34 | static bool s_detected = false; 35 | 36 | static void s_updateDevName() 37 | { 38 | const char *oplName = (s_type == OPLChipBase::CHIPTYPE_OPL3) ? "OPL3" : "OPL2"; 39 | memset(s_devName, 0, sizeof(s_devName)); 40 | snprintf(s_devName, 80, "%s at 0x%03X", oplName, s_OPLBase[0]); 41 | } 42 | 43 | static void s_detect() 44 | { 45 | if(s_detected) 46 | return; 47 | 48 | const char *blaster = getenv("BLASTER"); 49 | if(blaster) 50 | { 51 | size_t len = strlen(blaster); 52 | for(size_t i = 0; i < len - 1; ++i) 53 | { 54 | if(blaster[i] == 'T') 55 | { 56 | switch(blaster[i + 1]) 57 | { 58 | case '1': 59 | case '2': 60 | s_type = OPLChipBase::CHIPTYPE_OPL2; 61 | break; 62 | case '3': 63 | case '4': 64 | case '6': 65 | s_type = OPLChipBase::CHIPTYPE_OPL3; 66 | break; 67 | default: 68 | s_type = OPLChipBase::CHIPTYPE_OPL2; 69 | break; 70 | } 71 | 72 | // printf("-- Detected BLASTER T%c\n", blaster[i + 1]); 73 | 74 | break; 75 | } 76 | } 77 | } 78 | else 79 | s_type = OPLChipBase::CHIPTYPE_OPL2; 80 | 81 | s_detected = true; 82 | } 83 | 84 | DOS_HW_OPL::DOS_HW_OPL() 85 | { 86 | s_detect(); 87 | s_updateDevName(); 88 | } 89 | 90 | void DOS_HW_OPL::setOplAddress(uint16_t address) 91 | { 92 | s_OPLBase[0] = address; 93 | s_OPLBase[1] = address + 2; 94 | s_updateDevName(); 95 | } 96 | 97 | void DOS_HW_OPL::setChipType(ChipType type) 98 | { 99 | s_type = type; 100 | s_detected = true; // Assignd manually, no need to detect 101 | } 102 | 103 | DOS_HW_OPL::~DOS_HW_OPL() 104 | { 105 | DOS_HW_OPL::writeReg(0x0BD, 0); 106 | if(s_type == CHIPTYPE_OPL3) 107 | { 108 | DOS_HW_OPL::writeReg(0x104, 0); 109 | DOS_HW_OPL::writeReg(0x105, 0); 110 | } 111 | } 112 | 113 | void DOS_HW_OPL::writeReg(uint16_t addr, uint8_t data) 114 | { 115 | assert(m_id <= 1); 116 | unsigned o = addr >> 8; 117 | unsigned port = s_OPLBase[m_id] + o * 2; 118 | 119 | # ifdef __DJGPP__ 120 | outportb(port, addr); 121 | 122 | for(unsigned c = 0; c < 6; ++c) 123 | inportb(port); 124 | 125 | outportb(port + 1, data); 126 | 127 | for(unsigned c = 0; c < 35; ++c) 128 | inportb(port); 129 | # endif 130 | 131 | # ifdef __WATCOMC__ 132 | outp(port, addr); 133 | 134 | for(uint16_t c = 0; c < 6; ++c) 135 | inp(port); 136 | 137 | outp(port + 1, data); 138 | 139 | for(uint16_t c = 0; c < 35; ++c) 140 | inp(port); 141 | # endif//__WATCOMC__ 142 | } 143 | 144 | void DOS_HW_OPL::nativeGenerate(int16_t *frame) 145 | { 146 | frame[0] = 0; 147 | frame[1] = 0; 148 | } 149 | 150 | const char *DOS_HW_OPL::emulatorName() 151 | { 152 | return s_devName; 153 | } 154 | 155 | bool DOS_HW_OPL::hasFullPanning() 156 | { 157 | return false; 158 | } 159 | 160 | OPLChipBase::ChipType DOS_HW_OPL::chipType() 161 | { 162 | return s_type; 163 | } 164 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/dos_hw_opl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | 22 | #ifndef DOS_HW_OPL_H 23 | #define DOS_HW_OPL_H 24 | 25 | #include "opl_chip_base.h" 26 | 27 | class DOS_HW_OPL : public OPLChipBaseT 28 | { 29 | public: 30 | DOS_HW_OPL(); 31 | virtual ~DOS_HW_OPL() override; 32 | 33 | static void setChipType(ChipType type); 34 | static void setOplAddress(uint16_t address); 35 | 36 | bool canRunAtPcmRate() const override { return false; } 37 | void setRate(uint32_t /*rate*/) override {} 38 | void reset() override {} 39 | void writeReg(uint16_t addr, uint8_t data) override; 40 | void nativePreGenerate() override {} 41 | void nativePostGenerate() override {} 42 | void nativeGenerate(int16_t *frame) override; 43 | const char *emulatorName() override; 44 | ChipType chipType() override; 45 | bool hasFullPanning() override; 46 | }; 47 | 48 | #endif // DOS_HW_OPL_H 49 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/dosbox_opl3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "dosbox_opl3.h" 22 | #include "dosbox/dbopl.h" 23 | #include 24 | #include 25 | #include 26 | 27 | DosBoxOPL3::DosBoxOPL3() : 28 | OPLChipBaseBufferedT(), 29 | m_chip(new DBOPL::Handler) 30 | { 31 | DosBoxOPL3::reset(); 32 | } 33 | 34 | DosBoxOPL3::~DosBoxOPL3() 35 | { 36 | DBOPL::Handler *chip_r = reinterpret_cast(m_chip); 37 | delete chip_r; 38 | } 39 | 40 | void DosBoxOPL3::globalPreInit() 41 | { 42 | DBOPL::InitTables(); 43 | } 44 | 45 | void DosBoxOPL3::setRate(uint32_t rate) 46 | { 47 | OPLChipBaseBufferedT::setRate(rate); 48 | DBOPL::Handler *chip_r = reinterpret_cast(m_chip); 49 | chip_r->~Handler(); 50 | new(chip_r) DBOPL::Handler; 51 | chip_r->Init(effectiveRate()); 52 | } 53 | 54 | void DosBoxOPL3::reset() 55 | { 56 | OPLChipBaseBufferedT::reset(); 57 | DBOPL::Handler *chip_r = reinterpret_cast(m_chip); 58 | chip_r->~Handler(); 59 | new(chip_r) DBOPL::Handler; 60 | chip_r->Init(effectiveRate()); 61 | } 62 | 63 | void DosBoxOPL3::writeReg(uint16_t addr, uint8_t data) 64 | { 65 | DBOPL::Handler *chip_r = reinterpret_cast(m_chip); 66 | chip_r->WriteReg(static_cast(addr), data); 67 | } 68 | 69 | void DosBoxOPL3::writePan(uint16_t addr, uint8_t data) 70 | { 71 | DBOPL::Handler *chip_r = reinterpret_cast(m_chip); 72 | chip_r->WritePan(static_cast(addr), data); 73 | } 74 | 75 | void DosBoxOPL3::nativeGenerateN(int16_t *output, size_t frames) 76 | { 77 | DBOPL::Handler *chip_r = reinterpret_cast(m_chip); 78 | Bitu frames_i = frames; 79 | chip_r->GenerateArr(output, &frames_i); 80 | } 81 | 82 | const char *DosBoxOPL3::emulatorName() 83 | { 84 | return "DOSBox 0.74-r4111 OPL3"; 85 | } 86 | 87 | bool DosBoxOPL3::hasFullPanning() 88 | { 89 | return true; 90 | } 91 | 92 | OPLChipBase::ChipType DosBoxOPL3::chipType() 93 | { 94 | return CHIPTYPE_OPL3; 95 | } 96 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/dosbox_opl3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef DOSBOX_OPL3_H 22 | #define DOSBOX_OPL3_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class DosBoxOPL3 final : public OPLChipBaseBufferedT 27 | { 28 | void *m_chip; 29 | public: 30 | DosBoxOPL3(); 31 | ~DosBoxOPL3() override; 32 | 33 | static void globalPreInit(); 34 | 35 | bool canRunAtPcmRate() const override { return true; } 36 | void setRate(uint32_t rate) override; 37 | void reset() override; 38 | void writeReg(uint16_t addr, uint8_t data) override; 39 | void writePan(uint16_t addr, uint8_t data) override; 40 | void nativePreGenerate() override {} 41 | void nativePostGenerate() override {} 42 | void nativeGenerateN(int16_t *output, size_t frames) override; 43 | const char *emulatorName() override; 44 | ChipType chipType() override; 45 | bool hasFullPanning() override; 46 | }; 47 | 48 | #endif // DOSBOX_OPL3_H 49 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/esfmu/README.md: -------------------------------------------------------------------------------- 1 | # ESFMu 2 | 3 |

4 | 5 |

6 | 7 | An emulator for the ESS "ESFM" enhanced OPL3 clone, based on Nuke.YKT's **Nuked OPL3** and reverse-engineering efforts from the community. 8 | 9 | ## Acknowledgements 10 | 11 | I'd like to thank: 12 | 13 | - **Nuke.YKT** 14 | - Developer of **Nuked OPL3**, which was the basis for **ESFMu**'s code and also a great learning resource on Yamaha FM synthesis for myself. 15 | - Nuke.YKT also gives shoutouts on behalf of **Nuked OPL3** to: 16 | >- MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh): 17 | > - Feedback and Rhythm part calculation information. 18 | >- forums.submarine.org.uk(carbon14, opl3): 19 | > - Tremolo and phase generator calculation information. 20 | >- OPLx decapsulated(Matthew Gambrell, Olli Niemitalo): 21 | > - OPL2 ROMs. 22 | >- siliconpr0n.org(John McMaster, digshadow): 23 | > - YMF262 and VRC VII decaps and die shots. 24 | - **rainwarrior** 25 | - For performing the initial research on ESFM drivers and documenting ESS's patent on native mode operator organization. 26 | - **jwt27** 27 | - For kickstarting the ESFM research project and compiling rainwarrior's findings and more in an accessible document ("ESFM Demystified"). 28 | - **pachuco/CatButts** 29 | - For documenting ESS's patent on ESFM's feedback implementation, which was vital in getting **ESFMu**'s sound output to be accurate. 30 | - **akumanatt** 31 | - For helping out with code optimization. 32 | - **shadex/shidzy13** 33 | - For helping out with the nifty logo above, thanks! 34 | - And everybody who helped out with real hardware testing 35 | 36 | ## Usage 37 | 38 | To use **ESFMu**: 39 | 40 | - include the **esfm.h** header file into your source code 41 | - include the **esfm.c** and **esfm_registers.c** files into your build and link process 42 | - declare or allocate a variable of type `esfm_chip` somewhere in your code - this will hold the chip's state 43 | - use the function interface defined in **esfm.h** to interact with the `esfm_chip` structure 44 | 45 | ## Function interface 46 | 47 | If you're familiar with **Nuked OPL3**, you'll find many similarities in the function interface provided by **ESFMu**. There are a few things to point out, however: 48 | 49 | ### Buffered writes 50 | 51 | Just like **Nuked OPL3**, **ESFMu** offers buffered register writes. However, it offers them in two flavors: "legacy" and fast. 52 | 53 | The fast buffered register writes (`ESFM_write_reg_buffered_fast`) are recommended, since they offer minimal latency which is close to the behavior you'd get with the actual ESS drivers on Windows. 54 | 55 | The "legacy" buffered register writes are only recommended for specific cases, such as programs seeking for a shortcut to emulate the write delays from some sound drivers. 56 | 57 | ### Port-level access 58 | 59 | Unlike **Nuked OPL3**, **ESFMu** actually allows port-level access to the ESFM interface. This is relevant because the ESFM port interface is actually modal, meaning that its behavior changes depending on whether the chip is set to emulation (OPL3 compatibility) mode or native (ESFM) mode. 60 | 61 | Using port-level access allows for applications to not need to keep track of whether the chip is in native mode or not, nor to perform the port handling logic on their side. 62 | 63 | Applications that use the register-level access, on the other hand, need to take care to either stick to only one of the operating modes (either native or emulation), or handle the port mapping logic on their own side. 64 | 65 | ### Register readback 66 | 67 | ESFM allows for register contents to be read back through its ports, and **ESFMu** implements this functionality, both via dedicated register read functions and via the port read interface. 68 | 69 | Note that in ESFM, register contents can only be read back when the chip is set to native (ESFM) mode, not when the chip is in emulation mode (i.e. OPL3 compatibility mode). 70 | 71 | ## Licensing 72 | 73 | **ESFMu** is highly based on **Nuked OPL3**, which is licensed under the GNU Lesser General Public License version 2.1 or later. Therefore, **ESFMu** is licensed under the same license. 74 | 75 | If you'd like to obtain a grant to use **ESFMu** under different terms, you should get in contact with [Nuke.YKT](https://github.com/nukeykt) (author of **Nuked OPL3**) as well as with [Kagamiin~](https://github.com/Kagamiin) (yours truly). 76 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/esfmu/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/cpp/src/chips/esfmu/assets/logo.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/esfmu_opl3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "esfmu_opl3.h" 22 | #include "esfmu/esfm.h" 23 | #include 24 | 25 | ESFMuOPL3::ESFMuOPL3() : 26 | OPLChipBaseT() 27 | { 28 | m_chip = new esfm_chip; 29 | ESFMuOPL3::setRate(m_rate); 30 | } 31 | 32 | ESFMuOPL3::~ESFMuOPL3() 33 | { 34 | esfm_chip *chip_r = reinterpret_cast(m_chip); 35 | delete chip_r; 36 | } 37 | 38 | void ESFMuOPL3::setRate(uint32_t rate) 39 | { 40 | OPLChipBaseT::setRate(rate); 41 | esfm_chip *chip_r = reinterpret_cast(m_chip); 42 | std::memset(chip_r, 0, sizeof(esfm_chip)); 43 | ESFM_init(chip_r/*, rate*/); 44 | } 45 | 46 | void ESFMuOPL3::reset() 47 | { 48 | OPLChipBaseT::reset(); 49 | esfm_chip *chip_r = reinterpret_cast(m_chip); 50 | std::memset(chip_r, 0, sizeof(esfm_chip)); 51 | ESFM_init(chip_r/*, m_rate*/); 52 | } 53 | 54 | void ESFMuOPL3::writeReg(uint16_t addr, uint8_t data) 55 | { 56 | esfm_chip *chip_r = reinterpret_cast(m_chip); 57 | ESFM_write_reg_buffered_fast(chip_r, addr, data); 58 | } 59 | 60 | void ESFMuOPL3::writePan(uint16_t addr, uint8_t data) 61 | { 62 | // FIXME: Implement panning support 63 | // esfm_chip *chip_r = reinterpret_cast(m_chip); 64 | // ESFM_write?pan(chip_r, addr, data); 65 | (void)(addr); 66 | (void)(data); 67 | } 68 | 69 | void ESFMuOPL3::nativeGenerate(int16_t *frame) 70 | { 71 | esfm_chip *chip_r = reinterpret_cast(m_chip); 72 | ESFM_generate(chip_r, frame); 73 | } 74 | 75 | const char *ESFMuOPL3::emulatorName() 76 | { 77 | return "ESFMu"; 78 | } 79 | 80 | bool ESFMuOPL3::hasFullPanning() 81 | { 82 | return false; 83 | } 84 | 85 | OPLChipBase::ChipType ESFMuOPL3::chipType() 86 | { 87 | return CHIPTYPE_ESFM; 88 | } 89 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/esfmu_opl3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef ESFMU_OPL3_H 22 | #define ESFMU_OPL3_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class ESFMuOPL3 final : public OPLChipBaseT 27 | { 28 | void *m_chip; 29 | public: 30 | ESFMuOPL3(); 31 | ~ESFMuOPL3() override; 32 | 33 | bool canRunAtPcmRate() const override { return false; } 34 | void setRate(uint32_t rate) override; 35 | void reset() override; 36 | void writeReg(uint16_t addr, uint8_t data) override; 37 | void writePan(uint16_t addr, uint8_t data) override; 38 | void nativePreGenerate() override {} 39 | void nativePostGenerate() override {} 40 | void nativeGenerate(int16_t *frame) override; 41 | const char *emulatorName() override; 42 | ChipType chipType() override; 43 | bool hasFullPanning() override; 44 | }; 45 | 46 | #endif // ESFMU_OPL3_H 47 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/java_opl3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "java_opl3.h" 22 | #include "java/JavaOPL3.hpp" 23 | 24 | #ifndef M_PI 25 | #define M_PI 3.14159265358979323846 26 | #endif 27 | #ifndef M_SQRT1_2 28 | #define M_SQRT1_2 0.70710678118654752440 29 | #endif 30 | 31 | JavaOPL3::JavaOPL3() : 32 | OPLChipBaseBufferedT(), 33 | m_chip(new ADL_JavaOPL3::OPL3(true)) 34 | { 35 | JavaOPL3::reset(); 36 | } 37 | 38 | JavaOPL3::~JavaOPL3() 39 | { 40 | ADL_JavaOPL3::OPL3 *chip_r = reinterpret_cast(m_chip); 41 | delete chip_r; 42 | } 43 | 44 | void JavaOPL3::setRate(uint32_t rate) 45 | { 46 | OPLChipBaseBufferedT::setRate(rate); 47 | ADL_JavaOPL3::OPL3 *chip_r = reinterpret_cast(m_chip); 48 | chip_r->Reset(); 49 | 50 | float pan = sinf((float)M_SQRT1_2); 51 | for (unsigned channel = 0; channel < 18; ++channel) 52 | chip_r->SetPanning(channel, pan, pan); 53 | } 54 | 55 | void JavaOPL3::reset() 56 | { 57 | OPLChipBaseBufferedT::reset(); 58 | ADL_JavaOPL3::OPL3 *chip_r = reinterpret_cast(m_chip); 59 | chip_r->Reset(); 60 | } 61 | 62 | void JavaOPL3::writeReg(uint16_t addr, uint8_t data) 63 | { 64 | ADL_JavaOPL3::OPL3 *chip_r = reinterpret_cast(m_chip); 65 | chip_r->WriteReg(addr, data); 66 | } 67 | 68 | void JavaOPL3::writePan(uint16_t addr, uint8_t data) 69 | { 70 | ADL_JavaOPL3::OPL3 *chip_r = reinterpret_cast(m_chip); 71 | 72 | unsigned high = (addr >> 8) & 0x01; 73 | unsigned regm = addr & 0xff; 74 | unsigned channel = 9 * high + (regm & 0x0f); 75 | 76 | float phase = (data == 63 || data == 64) ? 63.5f : (float)data; 77 | phase *= (float)(M_PI / 2 / 127); 78 | chip_r->SetPanning(channel, cosf(phase), sinf(phase)); 79 | } 80 | 81 | void JavaOPL3::nativeGenerateN(int16_t *output, size_t frames) 82 | { 83 | ADL_JavaOPL3::OPL3 *chip_r = reinterpret_cast(m_chip); 84 | 85 | enum { maxframes = 256 }; 86 | 87 | float buf[2 * maxframes]; 88 | while(frames > 0) 89 | { 90 | memset(buf, 0, sizeof(buf)); 91 | 92 | size_t curframes = (frames < (size_t)maxframes) ? frames : (size_t)maxframes; 93 | chip_r->Update(buf, (int)curframes); 94 | 95 | size_t cursamples = 2 * curframes; 96 | for(size_t i = 0; i < cursamples; ++i) 97 | { 98 | int32_t sample = (int32_t)lround(4096 * buf[i]); 99 | sample = (sample > -32768) ? sample : -32768; 100 | sample = (sample < +32767) ? sample : +32767; 101 | output[i] = (int16_t)sample; 102 | } 103 | 104 | output += cursamples; 105 | frames -= curframes; 106 | } 107 | } 108 | 109 | const char *JavaOPL3::emulatorName() 110 | { 111 | return "Java 1.0.6 OPL3"; 112 | } 113 | 114 | bool JavaOPL3::hasFullPanning() 115 | { 116 | return true; 117 | } 118 | 119 | OPLChipBase::ChipType JavaOPL3::chipType() 120 | { 121 | return CHIPTYPE_OPL3; 122 | } 123 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/java_opl3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef JAVA_OPL3_H 22 | #define JAVA_OPL3_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class JavaOPL3 final : public OPLChipBaseBufferedT 27 | { 28 | void *m_chip; 29 | public: 30 | JavaOPL3(); 31 | ~JavaOPL3() override; 32 | 33 | bool canRunAtPcmRate() const override { return false; } 34 | void setRate(uint32_t rate) override; 35 | void reset() override; 36 | void writeReg(uint16_t addr, uint8_t data) override; 37 | void writePan(uint16_t addr, uint8_t data) override; 38 | void nativePreGenerate() override {} 39 | void nativePostGenerate() override {} 40 | void nativeGenerateN(int16_t *output, size_t frames) override; 41 | const char *emulatorName() override; 42 | ChipType chipType() override; 43 | bool hasFullPanning() override; 44 | }; 45 | 46 | #endif // JAVA_OPL3_H 47 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/mame/opl.h: -------------------------------------------------------------------------------- 1 | #ifndef OPL_H 2 | #define OPL_H 3 | 4 | // Abstract base class for OPL emulators 5 | 6 | class OPLEmul 7 | { 8 | public: 9 | OPLEmul() {} 10 | virtual ~OPLEmul() {} 11 | 12 | virtual void Reset() = 0; 13 | virtual void WriteReg(int reg, int v) = 0; 14 | virtual void Update(float *buffer, int length) = 0; 15 | virtual void UpdateS(short *buffer, int length) = 0; 16 | virtual void SetPanning(int c, float left, float right) = 0; 17 | }; 18 | 19 | OPLEmul *YM3812Create(bool stereo); 20 | 21 | #define OPL_SAMPLE_RATE 49716.0 22 | #define CENTER_PANNING_POWER 0.70710678118 /* [RH] volume at center for EQP */ 23 | #define ADLIB_CLOCK_MUL 24.0 24 | 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/mame_opl2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (ym3812) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "mame_opl2.h" 22 | #include "mame/opl.h" 23 | #include 24 | 25 | MameOPL2::MameOPL2() : 26 | OPLChipBaseT() 27 | { 28 | m_chip = YM3812Create(false); 29 | MameOPL2::setRate(m_rate); 30 | } 31 | 32 | MameOPL2::~MameOPL2() 33 | { 34 | OPLEmul *chip_r = reinterpret_cast(m_chip); 35 | delete chip_r; 36 | } 37 | 38 | void MameOPL2::setRate(uint32_t rate) 39 | { 40 | OPLChipBaseT::setRate(rate); 41 | OPLEmul *chip_r = reinterpret_cast(m_chip); 42 | chip_r->Reset(); 43 | } 44 | 45 | void MameOPL2::reset() 46 | { 47 | OPLChipBaseT::reset(); 48 | OPLEmul *chip_r = reinterpret_cast(m_chip); 49 | chip_r->Reset(); 50 | } 51 | 52 | void MameOPL2::writeReg(uint16_t addr, uint8_t data) 53 | { 54 | OPLEmul *chip_r = reinterpret_cast(m_chip); 55 | chip_r->WriteReg(addr, data); 56 | } 57 | 58 | void MameOPL2::nativeGenerate(int16_t *frame) 59 | { 60 | OPLEmul *chip_r = reinterpret_cast(m_chip); 61 | frame[0] = 0; 62 | chip_r->UpdateS(frame, 1); 63 | frame[1] = frame[0]; 64 | } 65 | 66 | const char *MameOPL2::emulatorName() 67 | { 68 | return "MAME OPL2"; 69 | } 70 | 71 | bool MameOPL2::hasFullPanning() 72 | { 73 | return false; 74 | } 75 | 76 | OPLChipBase::ChipType MameOPL2::chipType() 77 | { 78 | return CHIPTYPE_OPL2; 79 | } 80 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/mame_opl2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef MAME_OPL2_H 22 | #define MAME_OPL2_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class MameOPL2 final : public OPLChipBaseT 27 | { 28 | void *m_chip; 29 | 30 | public: 31 | MameOPL2(); 32 | ~MameOPL2() override; 33 | 34 | bool canRunAtPcmRate() const override { return false; } 35 | void setRate(uint32_t rate) override; 36 | void reset() override; 37 | void writeReg(uint16_t addr, uint8_t data) override; 38 | void nativePreGenerate() override {} 39 | void nativePostGenerate() override {} 40 | void nativeGenerate(int16_t *frame) override; 41 | const char *emulatorName() override; 42 | ChipType chipType() override; 43 | bool hasFullPanning() override; 44 | }; 45 | 46 | #endif // MAME_OPL2_H 47 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/nuked/nukedopl3.h: -------------------------------------------------------------------------------- 1 | /* Nuked OPL3 2 | * Copyright (C) 2013-2020 Nuke.YKT 3 | * 4 | * This file is part of Nuked OPL3. 5 | * 6 | * Nuked OPL3 is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 2.1 9 | * of the License, or (at your option) any later version. 10 | * 11 | * Nuked OPL3 is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Nuked OPL3. If not, see . 18 | 19 | * Nuked OPL3 emulator. 20 | * Thanks: 21 | * MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh): 22 | * Feedback and Rhythm part calculation information. 23 | * forums.submarine.org.uk(carbon14, opl3): 24 | * Tremolo and phase generator calculation information. 25 | * OPLx decapsulated(Matthew Gambrell, Olli Niemitalo): 26 | * OPL2 ROMs. 27 | * siliconpr0n.org(John McMaster, digshadow): 28 | * YMF262 and VRC VII decaps and die shots. 29 | * 30 | * version: 1.8 31 | */ 32 | 33 | #ifndef OPL_OPL3_H 34 | #define OPL_OPL3_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #include 41 | 42 | #ifndef OPL_ENABLE_STEREOEXT 43 | #define OPL_ENABLE_STEREOEXT 0 44 | #endif 45 | 46 | #ifndef OPL_FAST_WAVEGEN 47 | #define OPL_FAST_WAVEGEN 1 /* optimized waveform generation */ 48 | #endif 49 | 50 | #define OPL_WRITEBUF_SIZE 1024 51 | #define OPL_WRITEBUF_DELAY 2 52 | 53 | typedef struct _opl3_slot opl3_slot; 54 | typedef struct _opl3_channel opl3_channel; 55 | typedef struct _opl3_chip opl3_chip; 56 | 57 | struct _opl3_slot { 58 | opl3_channel *channel; 59 | opl3_chip *chip; 60 | int16_t out; 61 | int16_t fbmod; 62 | int16_t *mod; 63 | int16_t prout; 64 | uint16_t eg_rout; 65 | uint16_t eg_out; 66 | uint8_t eg_inc; 67 | uint8_t eg_gen; 68 | uint8_t eg_rate; 69 | uint8_t eg_ksl; 70 | uint8_t *trem; 71 | uint8_t reg_vib; 72 | uint8_t reg_type; 73 | uint8_t reg_ksr; 74 | uint8_t reg_mult; 75 | uint8_t reg_ksl; 76 | uint8_t reg_tl; 77 | uint8_t reg_ar; 78 | uint8_t reg_dr; 79 | uint8_t reg_sl; 80 | uint8_t reg_rr; 81 | uint8_t reg_wf; 82 | uint8_t key; 83 | uint32_t pg_reset; 84 | uint32_t pg_phase; 85 | uint16_t pg_phase_out; 86 | uint8_t slot_num; 87 | 88 | #if OPL_FAST_WAVEGEN 89 | uint16_t maskzero; 90 | uint8_t signpos; 91 | uint8_t phaseshift; 92 | #endif 93 | }; 94 | 95 | struct _opl3_channel { 96 | opl3_slot *slotz[2];/*Don't use "slots" keyword to avoid conflict with Qt applications*/ 97 | opl3_channel *pair; 98 | opl3_chip *chip; 99 | int16_t *out[4]; 100 | 101 | #if OPL_ENABLE_STEREOEXT 102 | int32_t leftpan; 103 | int32_t rightpan; 104 | #endif 105 | 106 | uint8_t chtype; 107 | uint16_t f_num; 108 | uint8_t block; 109 | uint8_t fb; 110 | uint8_t con; 111 | uint8_t alg; 112 | uint8_t ksv; 113 | uint16_t cha, chb; 114 | uint16_t chc, chd; 115 | uint16_t chl, chr; 116 | uint8_t ch_num; 117 | }; 118 | 119 | typedef struct _opl3_writebuf { 120 | uint64_t time; 121 | uint16_t reg; 122 | uint8_t data; 123 | } opl3_writebuf; 124 | 125 | struct _opl3_chip { 126 | opl3_channel channel[18]; 127 | opl3_slot slot[36]; 128 | uint16_t timer; 129 | uint64_t eg_timer; 130 | uint8_t eg_timerrem; 131 | uint8_t eg_state; 132 | uint8_t eg_add; 133 | uint8_t newm; 134 | uint8_t nts; 135 | uint8_t rhy; 136 | uint8_t vibpos; 137 | uint8_t vibshift; 138 | uint8_t tremolo; 139 | uint8_t tremolopos; 140 | uint8_t tremoloshift; 141 | uint32_t noise; 142 | int16_t zeromod; 143 | int32_t mixbuff[4]; 144 | uint8_t rm_hh_bit2; 145 | uint8_t rm_hh_bit3; 146 | uint8_t rm_hh_bit7; 147 | uint8_t rm_hh_bit8; 148 | uint8_t rm_tc_bit3; 149 | uint8_t rm_tc_bit5; 150 | 151 | #if OPL_ENABLE_STEREOEXT 152 | uint8_t stereoext; 153 | #endif 154 | 155 | /* OPL3L */ 156 | int32_t rateratio; 157 | int32_t samplecnt; 158 | int16_t oldsamples[4]; 159 | int16_t samples[4]; 160 | 161 | uint64_t writebuf_samplecnt; 162 | uint32_t writebuf_cur; 163 | uint32_t writebuf_last; 164 | uint64_t writebuf_lasttime; 165 | opl3_writebuf writebuf[OPL_WRITEBUF_SIZE]; 166 | }; 167 | 168 | void OPL3_Generate(opl3_chip *chip, int16_t *buf); 169 | void OPL3_GenerateResampled(opl3_chip *chip, int16_t *buf); 170 | void OPL3_Reset(opl3_chip *chip, uint32_t samplerate); 171 | void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v); 172 | void OPL3_WriteRegBuffered(opl3_chip *chip, uint16_t reg, uint8_t v); 173 | void OPL3_WritePan(opl3_chip *chip, uint16_t reg, uint8_t v); 174 | void OPL3_GenerateStream(opl3_chip *chip, int16_t *sndptr, uint32_t numsamples); 175 | 176 | void OPL3_Generate4Ch(opl3_chip *chip, int16_t *buf4); 177 | void OPL3_Generate4ChResampled(opl3_chip *chip, int16_t *buf4); 178 | void OPL3_Generate4ChStream(opl3_chip *chip, int16_t *sndptr1, int16_t *sndptr2, uint32_t numsamples); 179 | 180 | #ifdef __cplusplus 181 | } 182 | #endif 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/nuked/nukedopl3_174.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2016 Alexey Khokholov (Nuke.YKT) 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.1 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 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | * 18 | * Nuked OPL3 emulator. 19 | * Thanks: 20 | * MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh): 21 | * Feedback and Rhythm part calculation information. 22 | * forums.submarine.org.uk(carbon14, opl3): 23 | * Tremolo and phase generator calculation information. 24 | * OPLx decapsulated(Matthew Gambrell, Olli Niemitalo): 25 | * OPL2 ROMs. 26 | * 27 | * version: 1.7.4 28 | */ 29 | 30 | #ifndef OPL_OPL3_H 31 | #define OPL_OPL3_H 32 | 33 | #include 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | 41 | #define OPL_WRITEBUF_SIZE 1024 42 | #define OPL_WRITEBUF_DELAY 2 43 | 44 | typedef uintptr_t Bitu; 45 | typedef intptr_t Bits; 46 | typedef uint64_t Bit64u; 47 | typedef int64_t Bit64s; 48 | typedef uint32_t Bit32u; 49 | typedef int32_t Bit32s; 50 | typedef uint16_t Bit16u; 51 | typedef int16_t Bit16s; 52 | typedef uint8_t Bit8u; 53 | typedef int8_t Bit8s; 54 | 55 | typedef struct _opl3_slot opl3_slot; 56 | typedef struct _opl3_channel opl3_channel; 57 | typedef struct _opl3_chip opl3_chip; 58 | 59 | struct _opl3_slot { 60 | opl3_channel *channel; 61 | opl3_chip *chip; 62 | Bit16s out; 63 | Bit16s fbmod; 64 | Bit16s *mod; 65 | Bit16s prout; 66 | Bit16s eg_rout; 67 | Bit16s eg_out; 68 | Bit8u eg_inc; 69 | Bit8u eg_gen; 70 | Bit8u eg_rate; 71 | Bit8u eg_ksl; 72 | Bit8u *trem; 73 | Bit8u reg_vib; 74 | Bit8u reg_type; 75 | Bit8u reg_ksr; 76 | Bit8u reg_mult; 77 | Bit8u reg_ksl; 78 | Bit8u reg_tl; 79 | Bit8u reg_ar; 80 | Bit8u reg_dr; 81 | Bit8u reg_sl; 82 | Bit8u reg_rr; 83 | Bit8u reg_wf; 84 | Bit8u key; 85 | Bit32u pg_phase; 86 | Bit32u timer; 87 | 88 | Bit16u maskzero; 89 | Bit8u signpos; 90 | Bit8u phaseshift; 91 | }; 92 | 93 | struct _opl3_channel { 94 | opl3_slot *slotz[2];/*Don't use "slots" keyword to avoid conflict with Qt applications*/ 95 | opl3_channel *pair; 96 | opl3_chip *chip; 97 | Bit16s *out[4]; 98 | Bit8u chtype; 99 | Bit16u f_num; 100 | Bit8u block; 101 | Bit8u fb; 102 | Bit8u con; 103 | Bit8u alg; 104 | Bit8u ksv; 105 | Bit16u cha, chb; 106 | Bit16u chl, chr; 107 | }; 108 | 109 | typedef struct _opl3_writebuf { 110 | Bit64u time; 111 | Bit16u reg; 112 | Bit8u data; 113 | } opl3_writebuf; 114 | 115 | struct _opl3_chip { 116 | opl3_channel channel[18]; 117 | opl3_slot chipslot[36]; 118 | Bit16u timer; 119 | Bit8u newm; 120 | Bit8u nts; 121 | Bit8u rhy; 122 | Bit8u vibpos; 123 | Bit8u vibshift; 124 | Bit8u tremolo; 125 | Bit8u tremolopos; 126 | Bit8u tremoloshift; 127 | Bit32u noise; 128 | Bit16s zeromod; 129 | Bit32s mixbuff[2]; 130 | /* OPL3L */ 131 | Bit32s rateratio; 132 | Bit32s samplecnt; 133 | Bit16s oldsamples[2]; 134 | Bit16s samples[2]; 135 | 136 | Bit64u writebuf_samplecnt; 137 | Bit32u writebuf_cur; 138 | Bit32u writebuf_last; 139 | Bit64u writebuf_lasttime; 140 | opl3_writebuf writebuf[OPL_WRITEBUF_SIZE]; 141 | }; 142 | 143 | void OPL3v17_Generate(opl3_chip *chip, Bit16s *buf); 144 | void OPL3v17_GenerateResampled(opl3_chip *chip, Bit16s *buf); 145 | void OPL3v17_Reset(opl3_chip *chip, Bit32u samplerate); 146 | void OPL3v17_WritePan(opl3_chip *chip, Bit16u reg, Bit8u v); 147 | void OPL3v17_WriteReg(opl3_chip *chip, Bit16u reg, Bit8u v); 148 | void OPL3v17_WriteRegBuffered(opl3_chip *chip, Bit16u reg, Bit8u v); 149 | void OPL3v17_GenerateStream(opl3_chip *chip, Bit16s *sndptr, Bit32u numsamples); 150 | void OPL3v17_GenerateStreamMix(opl3_chip *chip, Bit16s *sndptr, Bit32u numsamples); 151 | 152 | #ifdef __cplusplus 153 | } 154 | #endif 155 | 156 | #endif 157 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/nuked_opl3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "nuked_opl3.h" 22 | #include "nuked/nukedopl3.h" 23 | #include 24 | 25 | NukedOPL3::NukedOPL3() : 26 | OPLChipBaseT() 27 | { 28 | m_chip = new opl3_chip; 29 | NukedOPL3::setRate(m_rate); 30 | } 31 | 32 | NukedOPL3::~NukedOPL3() 33 | { 34 | opl3_chip *chip_r = reinterpret_cast(m_chip); 35 | delete chip_r; 36 | } 37 | 38 | void NukedOPL3::setRate(uint32_t rate) 39 | { 40 | OPLChipBaseT::setRate(rate); 41 | opl3_chip *chip_r = reinterpret_cast(m_chip); 42 | std::memset(chip_r, 0, sizeof(opl3_chip)); 43 | OPL3_Reset(chip_r, rate); 44 | } 45 | 46 | void NukedOPL3::reset() 47 | { 48 | OPLChipBaseT::reset(); 49 | opl3_chip *chip_r = reinterpret_cast(m_chip); 50 | std::memset(chip_r, 0, sizeof(opl3_chip)); 51 | OPL3_Reset(chip_r, m_rate); 52 | } 53 | 54 | void NukedOPL3::writeReg(uint16_t addr, uint8_t data) 55 | { 56 | opl3_chip *chip_r = reinterpret_cast(m_chip); 57 | OPL3_WriteRegBuffered(chip_r, addr, data); 58 | } 59 | 60 | void NukedOPL3::writePan(uint16_t addr, uint8_t data) 61 | { 62 | opl3_chip *chip_r = reinterpret_cast(m_chip); 63 | OPL3_WritePan(chip_r, addr, data); 64 | } 65 | 66 | void NukedOPL3::nativeGenerate(int16_t *frame) 67 | { 68 | opl3_chip *chip_r = reinterpret_cast(m_chip); 69 | OPL3_Generate(chip_r, frame); 70 | } 71 | 72 | const char *NukedOPL3::emulatorName() 73 | { 74 | return "Nuked OPL3 (v 1.8)"; 75 | } 76 | 77 | bool NukedOPL3::hasFullPanning() 78 | { 79 | return true; 80 | } 81 | 82 | OPLChipBase::ChipType NukedOPL3::chipType() 83 | { 84 | return CHIPTYPE_OPL3; 85 | } 86 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/nuked_opl3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef NUKED_OPL3_H 22 | #define NUKED_OPL3_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class NukedOPL3 final : public OPLChipBaseT 27 | { 28 | void *m_chip; 29 | public: 30 | NukedOPL3(); 31 | ~NukedOPL3() override; 32 | 33 | bool canRunAtPcmRate() const override { return false; } 34 | void setRate(uint32_t rate) override; 35 | void reset() override; 36 | void writeReg(uint16_t addr, uint8_t data) override; 37 | void writePan(uint16_t addr, uint8_t data) override; 38 | void nativePreGenerate() override {} 39 | void nativePostGenerate() override {} 40 | void nativeGenerate(int16_t *frame) override; 41 | const char *emulatorName() override; 42 | ChipType chipType() override; 43 | bool hasFullPanning() override; 44 | }; 45 | 46 | #endif // NUKED_OPL3_H 47 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/nuked_opl3_v174.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "nuked_opl3_v174.h" 22 | #include "nuked/nukedopl3_174.h" 23 | #include 24 | 25 | NukedOPL3v174::NukedOPL3v174() : 26 | OPLChipBaseT() 27 | { 28 | m_chip = new opl3_chip; 29 | NukedOPL3v174::setRate(m_rate); 30 | } 31 | 32 | NukedOPL3v174::~NukedOPL3v174() 33 | { 34 | opl3_chip *chip_r = reinterpret_cast(m_chip); 35 | delete chip_r; 36 | } 37 | 38 | void NukedOPL3v174::setRate(uint32_t rate) 39 | { 40 | OPLChipBaseT::setRate(rate); 41 | opl3_chip *chip_r = reinterpret_cast(m_chip); 42 | std::memset(chip_r, 0, sizeof(opl3_chip)); 43 | OPL3v17_Reset(chip_r, rate); 44 | } 45 | 46 | void NukedOPL3v174::reset() 47 | { 48 | OPLChipBaseT::reset(); 49 | opl3_chip *chip_r = reinterpret_cast(m_chip); 50 | std::memset(chip_r, 0, sizeof(opl3_chip)); 51 | OPL3v17_Reset(chip_r, m_rate); 52 | } 53 | 54 | void NukedOPL3v174::writeReg(uint16_t addr, uint8_t data) 55 | { 56 | opl3_chip *chip_r = reinterpret_cast(m_chip); 57 | OPL3v17_WriteReg(chip_r, addr, data); 58 | } 59 | 60 | void NukedOPL3v174::writePan(uint16_t addr, uint8_t data) 61 | { 62 | opl3_chip *chip_r = reinterpret_cast(m_chip); 63 | OPL3v17_WritePan(chip_r, addr, data); 64 | } 65 | 66 | void NukedOPL3v174::nativeGenerate(int16_t *frame) 67 | { 68 | opl3_chip *chip_r = reinterpret_cast(m_chip); 69 | OPL3v17_Generate(chip_r, frame); 70 | } 71 | 72 | const char *NukedOPL3v174::emulatorName() 73 | { 74 | return "Nuked OPL3 (v 1.7.4)"; 75 | } 76 | 77 | bool NukedOPL3v174::hasFullPanning() 78 | { 79 | return true; 80 | } 81 | 82 | OPLChipBase::ChipType NukedOPL3v174::chipType() 83 | { 84 | return CHIPTYPE_OPL3; 85 | } 86 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/nuked_opl3_v174.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef NUKED_OPL3174_H 22 | #define NUKED_OPL3174_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class NukedOPL3v174 final : public OPLChipBaseT 27 | { 28 | void *m_chip; 29 | public: 30 | NukedOPL3v174(); 31 | ~NukedOPL3v174() override; 32 | 33 | bool canRunAtPcmRate() const override { return false; } 34 | void setRate(uint32_t rate) override; 35 | void reset() override; 36 | void writeReg(uint16_t addr, uint8_t data) override; 37 | void writePan(uint16_t addr, uint8_t data) override; 38 | void nativePreGenerate() override {} 39 | void nativePostGenerate() override {} 40 | void nativeGenerate(int16_t *frame) override; 41 | const char *emulatorName() override; 42 | ChipType chipType() override; 43 | bool hasFullPanning() override; 44 | }; 45 | 46 | #endif // NUKED_OPL3174_H 47 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/opal/LICENSE.txt: -------------------------------------------------------------------------------- 1 | A quote from a letter sent by Willy Reeve to Vitaly Novichkov 2 | as a reply from a letter sent by Reality's (https://www.3eality.com/) 3 | contact form 4 | ---------------------------------------------------------------- 5 | All source code supplied with RAD is in the public domain. 6 | ---------------------------------------------------------------- 7 | 8 | ================================================================ 9 | The complete letter: 10 | ================================================================ 11 | Hi, 12 | 13 | All source code supplied with RAD is in the public domain. 14 | We'll clarify that in the documentation for the next release. 15 | 16 | Later... 17 | SHAYDE 18 | ================================================================ 19 | 20 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/opal/old/LICENSE.txt: -------------------------------------------------------------------------------- 1 | A quote from a letter sent by Willy Reeve to Vitaly Novichkov 2 | as a reply from a letter sent by Reality's (https://www.3eality.com/) 3 | contact form 4 | ---------------------------------------------------------------- 5 | All source code supplied with RAD is in the public domain. 6 | ---------------------------------------------------------------- 7 | 8 | ================================================================ 9 | The complete letter: 10 | ================================================================ 11 | Hi, 12 | 13 | All source code supplied with RAD is in the public domain. 14 | We'll clarify that in the documentation for the next release. 15 | 16 | Later... 17 | SHAYDE 18 | ================================================================ 19 | 20 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/opal/old/README.old: -------------------------------------------------------------------------------- 1 | Copy opal.cpp here to make this emulator available. 2 | This is not distributed with the software while the license is undetermined. 3 | 4 | The opal.cpp file is part of REALITY ADLIB TRACKER V2. 5 | SHA1: c034dd637887d81770cee92da309fc547ef5fe18 6 | 7 | Configure the software with the option USE_OPAL_EMULATOR=ON. 8 | To enable soft panning, it is needed to patch with the file `opal-pan.diff` provided. 9 | for example: `patch -p0 -i opal-pan.diff` 10 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/opal/old/opal-pan.diff: -------------------------------------------------------------------------------- 1 | --- opal.cpp.orig 2019-02-23 20:32:00.477658789 +0100 2 | +++ opal.cpp 2019-02-23 20:46:36.745113958 +0100 3 | @@ -13,6 +13,7 @@ 4 | - Percussion mode 5 | 6 | */ 7 | +#define OPAL_HAVE_SOFT_PANNING 1 /* libADLMIDI */ 8 | 9 | 10 | 11 | @@ -133,6 +134,7 @@ 12 | void SetOctave(uint16_t oct); 13 | void SetLeftEnable(bool on); 14 | void SetRightEnable(bool on); 15 | + void SetPan(uint8_t pan); 16 | void SetFeedback(uint16_t val); 17 | void SetModulationType(uint16_t type); 18 | 19 | @@ -158,6 +160,7 @@ 20 | Channel * ChannelPair; 21 | bool Enable; 22 | bool LeftEnable, RightEnable; 23 | + uint16_t LeftPan, RightPan; 24 | }; 25 | 26 | public: 27 | @@ -166,6 +169,7 @@ 28 | 29 | void SetSampleRate(int sample_rate); 30 | void Port(uint16_t reg_num, uint8_t val); 31 | + void Pan(uint16_t reg_num, uint8_t pan); 32 | void Sample(int16_t *left, int16_t *right); 33 | 34 | protected: 35 | @@ -191,6 +195,7 @@ 36 | static const uint16_t RateTables[4][8]; 37 | static const uint16_t ExpTable[256]; 38 | static const uint16_t LogSinTable[256]; 39 | + static const uint16_t PanLawTable[128]; 40 | }; 41 | //-------------------------------------------------------------------------------------------------- 42 | const uint16_t Opal::RateTables[4][8] = { 43 | @@ -237,6 +242,28 @@ 44 | 7, 7, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 45 | 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 46 | }; 47 | +//-------------------------------------------------------------------------------------------------- 48 | +const uint16_t Opal::PanLawTable[128] = 49 | +{ 50 | + 65535, 65529, 65514, 65489, 65454, 65409, 65354, 65289, 51 | + 65214, 65129, 65034, 64929, 64814, 64689, 64554, 64410, 52 | + 64255, 64091, 63917, 63733, 63540, 63336, 63123, 62901, 53 | + 62668, 62426, 62175, 61914, 61644, 61364, 61075, 60776, 54 | + 60468, 60151, 59825, 59489, 59145, 58791, 58428, 58057, 55 | + 57676, 57287, 56889, 56482, 56067, 55643, 55211, 54770, 56 | + 54320, 53863, 53397, 52923, 52441, 51951, 51453, 50947, 57 | + 50433, 49912, 49383, 48846, 48302, 47750, 47191, 58 | + 46340, // Center left 59 | + 46340, // Center right 60 | + 45472, 44885, 44291, 43690, 43083, 42469, 41848, 41221, 61 | + 40588, 39948, 39303, 38651, 37994, 37330, 36661, 35986, 62 | + 35306, 34621, 33930, 33234, 32533, 31827, 31116, 30400, 63 | + 29680, 28955, 28225, 27492, 26754, 26012, 25266, 24516, 64 | + 23762, 23005, 22244, 21480, 20713, 19942, 19169, 18392, 65 | + 17613, 16831, 16046, 15259, 14469, 13678, 12884, 12088, 66 | + 11291, 10492, 9691, 8888, 8085, 7280, 6473, 5666, 67 | + 4858, 4050, 3240, 2431, 1620, 810, 0 68 | +}; 69 | 70 | 71 | 72 | @@ -342,6 +369,10 @@ 73 | for (int i = 0; i < NumOperators; i++) 74 | Op[i].ComputeRates(); 75 | 76 | + // Initialise channel panning at center. 77 | + for (int i = 0; i < NumChannels; i++) 78 | + Chan[i].SetPan(64); 79 | + 80 | SetSampleRate(sample_rate); 81 | } 82 | 83 | @@ -533,6 +564,19 @@ 84 | 85 | 86 | //================================================================================================== 87 | +// Set panning on the channel designated by the register number. 88 | +// This is extended functionality. 89 | +//================================================================================================== 90 | +void Opal::Pan(uint16_t reg_num, uint8_t pan) 91 | +{ 92 | + uint8_t high = (reg_num >> 8) & 1; 93 | + uint8_t regm = reg_num & 0xff; 94 | + Chan[9 * high + (regm & 0x0f)].SetPan(pan); 95 | +} 96 | + 97 | + 98 | + 99 | +//================================================================================================== 100 | // Generate sample. Every time you call this you will get two signed 16-bit samples (one for each 101 | // stereo channel) which will sound correct when played back at the sample rate given when the 102 | // class was constructed. 103 | @@ -727,6 +771,9 @@ 104 | 105 | left = LeftEnable ? out : 0; 106 | right = RightEnable ? out : 0; 107 | + 108 | + left = left * LeftPan / 65536; 109 | + right = right * RightPan / 65536; 110 | } 111 | 112 | 113 | @@ -793,6 +840,18 @@ 114 | } 115 | 116 | 117 | + 118 | +//================================================================================================== 119 | +// Pan the channel to the position given. 120 | +//================================================================================================== 121 | +void Opal::Channel::SetPan(uint8_t pan) 122 | +{ 123 | + pan &= 127; 124 | + LeftPan = PanLawTable[pan]; 125 | + RightPan = PanLawTable[127 - pan]; 126 | +} 127 | + 128 | + 129 | 130 | //================================================================================================== 131 | // Set the channel feedback amount. 132 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/opal/opal.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | The Opal OPL3 emulator. 4 | 5 | Note: this is not a complete emulator, just enough for Reality Adlib Tracker tunes. 6 | 7 | Missing features compared to a real OPL3: 8 | 9 | - Timers/interrupts 10 | - OPL3 enable bit (it defaults to always on) 11 | - CSW mode 12 | - Test register 13 | - Percussion mode 14 | 15 | */ 16 | 17 | #ifndef OPAL_HHHH 18 | #define OPAL_HHHH 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #define OPAL_TRUE 1 27 | #define OPAL_FALSE 0 28 | typedef int opal_bool; 29 | 30 | typedef struct OpalChannel_t OpalChannel; 31 | typedef struct OpalOperator_t OpalOperator; 32 | typedef struct Opal_t Opal; 33 | 34 | /* Various constants */ 35 | typedef enum OpalEnum_t 36 | { 37 | OpalOPL3SampleRate = 49716, 38 | OpalNumChannels = 18, 39 | OpalNumOperators = 36 40 | } OpalEnum; 41 | 42 | /* A single FM operator */ 43 | struct OpalOperator_t 44 | { 45 | Opal* Master; /* Master object */ 46 | OpalChannel* Chan; /* Owning channel */ 47 | uint32_t Phase; /* The current offset in the selected waveform */ 48 | uint16_t Waveform; /* The waveform id this operator is using */ 49 | uint16_t FreqMultTimes2; /* Frequency multiplier * 2 */ 50 | int EnvelopeStage; /* Which stage the envelope is at (see Env* enums above) */ 51 | int16_t EnvelopeLevel; /* 0 - $1FF, 0 being the loudest */ 52 | uint16_t OutputLevel; /* 0 - $FF */ 53 | uint16_t AttackRate; 54 | uint16_t DecayRate; 55 | uint16_t SustainLevel; 56 | uint16_t ReleaseRate; 57 | uint16_t AttackShift; 58 | uint16_t AttackMask; 59 | uint16_t AttackAdd; 60 | const uint16_t* AttackTab; 61 | uint16_t DecayShift; 62 | uint16_t DecayMask; 63 | uint16_t DecayAdd; 64 | const uint16_t* DecayTab; 65 | uint16_t ReleaseShift; 66 | uint16_t ReleaseMask; 67 | uint16_t ReleaseAdd; 68 | const uint16_t* ReleaseTab; 69 | uint16_t KeyScaleShift; 70 | uint16_t KeyScaleLevel; 71 | int16_t Out[2]; 72 | opal_bool KeyOn; 73 | opal_bool KeyScaleRate; /* Affects envelope rate scaling */ 74 | opal_bool SustainMode; /* Whether to sustain during the sustain phase, or release instead */ 75 | opal_bool TremoloEnable; 76 | opal_bool VibratoEnable; 77 | }; 78 | 79 | /* A single channel, which can contain two or more operators */ 80 | struct OpalChannel_t 81 | { 82 | OpalOperator* Op[4]; 83 | 84 | Opal* Master; /* Master object */ 85 | uint16_t Freq; /* Frequency; actually it's a phase stepping value */ 86 | uint16_t Octave; /* Also known as "block" in Yamaha parlance */ 87 | uint32_t PhaseStep; 88 | uint16_t KeyScaleNumber; 89 | uint16_t FeedbackShift; 90 | uint16_t ModulationType; 91 | OpalChannel* ChannelPair; 92 | opal_bool Enable; 93 | opal_bool LeftEnable, RightEnable; 94 | uint16_t LeftPan, RightPan; 95 | }; 96 | 97 | 98 | /*================================================================================================== 99 | Opal instance. 100 | ==================================================================================================*/ 101 | struct Opal_t 102 | { 103 | int32_t SampleRate; 104 | int32_t SampleAccum; 105 | int16_t LastOutput[2], CurrOutput[2]; 106 | OpalChannel Chan[OpalNumChannels]; 107 | OpalOperator Op[OpalNumOperators]; 108 | uint16_t Clock; 109 | uint16_t TremoloClock; 110 | uint16_t TremoloLevel; 111 | uint16_t VibratoTick; 112 | uint16_t VibratoClock; 113 | opal_bool NoteSel; 114 | opal_bool TremoloDepth; 115 | opal_bool VibratoDepth; 116 | }; 117 | 118 | 119 | /*================================================================================================== 120 | Public API. 121 | ==================================================================================================*/ 122 | /*! 123 | * \brief Initialize Opal with a given output sample rate 124 | * \param self Pointer to the Opal instance 125 | * \param sample_rate Desired output sample rate 126 | */ 127 | extern void Opal_Init(Opal *self, int sample_rate); 128 | 129 | /*! 130 | * \brief Change the output sample rate of existing initialized instance 131 | * \param self Pointer to the Opal instance 132 | * \param sample_rate Desired output sample rate 133 | */ 134 | extern void Opal_SetSampleRate(Opal *self, int sample_rate); 135 | 136 | /*! 137 | * \brief Send the register data to the Opal 138 | * \param self Pointer to the Opal instance 139 | * \param reg_num OPL3 Register address 140 | * \param val Value to write 141 | */ 142 | extern void Opal_Port(Opal *self, uint16_t reg_num, uint8_t val); 143 | 144 | /*! 145 | * \brief Panorama level per channel 146 | * \param self Pointer to the Opal instance 147 | * \param reg_num Channel number (multiplied by 256) 148 | * \param pan Panorama level (0 - left, 64 - middle, 127 - right) 149 | */ 150 | extern void Opal_Pan(Opal *self, uint16_t reg_num, uint8_t pan); 151 | 152 | /*! 153 | * \brief Generate one 16-bit PCM sample in system endian (there are two integers will be written) 154 | * \param self Pointer to the Opal instance 155 | * \param left Sample for the left chanel 156 | * \param right Sample for the right channel 157 | */ 158 | extern void Opal_Sample(Opal *self, int16_t* left, int16_t* right); 159 | 160 | 161 | #ifdef __cplusplus 162 | } 163 | #endif 164 | 165 | #endif /* OPAL_HHHH */ 166 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/opal_opl3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "opal_opl3.h" 22 | #include "opal/opal.h" 23 | #include 24 | 25 | OpalOPL3::OpalOPL3() : 26 | OPLChipBaseT() 27 | { 28 | m_chip = new Opal; 29 | OpalOPL3::setRate(m_rate); 30 | } 31 | 32 | OpalOPL3::~OpalOPL3() 33 | { 34 | Opal *chip_r = reinterpret_cast(m_chip); 35 | delete chip_r; 36 | } 37 | 38 | void OpalOPL3::setRate(uint32_t rate) 39 | { 40 | OPLChipBaseT::setRate(rate); 41 | Opal *chip_r = reinterpret_cast(m_chip); 42 | std::memset(chip_r, 0, sizeof(Opal)); 43 | Opal_Init(chip_r, effectiveRate()); 44 | } 45 | 46 | void OpalOPL3::reset() 47 | { 48 | OPLChipBaseT::reset(); 49 | Opal *chip_r = reinterpret_cast(m_chip); 50 | std::memset(chip_r, 0, sizeof(Opal)); 51 | Opal_Init(chip_r, effectiveRate()); 52 | } 53 | 54 | void OpalOPL3::writeReg(uint16_t addr, uint8_t data) 55 | { 56 | Opal *chip_r = reinterpret_cast(m_chip); 57 | Opal_Port(chip_r, addr, data); 58 | } 59 | 60 | void OpalOPL3::writePan(uint16_t addr, uint8_t data) 61 | { 62 | Opal *chip_r = reinterpret_cast(m_chip); 63 | Opal_Pan(chip_r, addr, data); 64 | } 65 | 66 | void OpalOPL3::nativeGenerate(int16_t *frame) 67 | { 68 | Opal *chip_r = reinterpret_cast(m_chip); 69 | Opal_Sample(chip_r, &frame[0], &frame[1]); 70 | } 71 | 72 | const char *OpalOPL3::emulatorName() 73 | { 74 | return "Opal OPL3"; 75 | } 76 | 77 | bool OpalOPL3::hasFullPanning() 78 | { 79 | return true; 80 | } 81 | 82 | OPLChipBase::ChipType OpalOPL3::chipType() 83 | { 84 | return CHIPTYPE_OPL3; 85 | } 86 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/opal_opl3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef OPAL_OPL3_H 22 | #define OPAL_OPL3_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class OpalOPL3 final : public OPLChipBaseT 27 | { 28 | void *m_chip; 29 | public: 30 | OpalOPL3(); 31 | ~OpalOPL3() override; 32 | 33 | bool canRunAtPcmRate() const override { return true; } 34 | void setRate(uint32_t rate) override; 35 | void reset() override; 36 | void writeReg(uint16_t addr, uint8_t data) override; 37 | void writePan(uint16_t addr, uint8_t data) override; 38 | void nativePreGenerate() override {} 39 | void nativePostGenerate() override {} 40 | void nativeGenerate(int16_t *frame) override; 41 | const char *emulatorName() override; 42 | ChipType chipType() override; 43 | bool hasFullPanning() override; 44 | }; 45 | 46 | #endif // NUKED_OPL3_H 47 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/opl_chip_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 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.1 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 Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef ONP_CHIP_BASE_H 20 | #define ONP_CHIP_BASE_H 21 | 22 | #include 23 | #include 24 | 25 | #if !defined(_MSC_VER) && (__cplusplus <= 199711L) 26 | #define final 27 | #define override 28 | #endif 29 | 30 | #if defined(ADLMIDI_ENABLE_HQ_RESAMPLER) 31 | class VResampler; 32 | #endif 33 | 34 | #if defined(ADLMIDI_AUDIO_TICK_HANDLER) 35 | extern void adl_audioTickHandler(void *instance, uint32_t chipId, uint32_t rate); 36 | #endif 37 | 38 | class OPLChipBase 39 | { 40 | public: 41 | enum { nativeRate = 49716 }; 42 | enum ChipType 43 | { 44 | CHIPTYPE_OPL3 = 0, 45 | CHIPTYPE_OPL2 = 1, 46 | CHIPTYPE_ESFM = 2 47 | }; 48 | protected: 49 | uint32_t m_id; 50 | uint32_t m_rate; 51 | public: 52 | OPLChipBase(); 53 | virtual ~OPLChipBase(); 54 | 55 | uint32_t chipId() const { return m_id; } 56 | void setChipId(uint32_t id) { m_id = id; } 57 | 58 | virtual bool canRunAtPcmRate() const = 0; 59 | virtual bool isRunningAtPcmRate() const = 0; 60 | virtual bool setRunningAtPcmRate(bool r) = 0; 61 | #if defined(ADLMIDI_AUDIO_TICK_HANDLER) 62 | virtual void setAudioTickHandlerInstance(void *instance) = 0; 63 | #endif 64 | 65 | virtual void setRate(uint32_t rate) = 0; 66 | virtual uint32_t effectiveRate() const = 0; 67 | virtual void reset() = 0; 68 | virtual void writeReg(uint16_t addr, uint8_t data) = 0; 69 | 70 | // extended 71 | virtual void writePan(uint16_t addr, uint8_t data) { (void)addr; (void)data; } 72 | 73 | virtual void nativePreGenerate() = 0; 74 | virtual void nativePostGenerate() = 0; 75 | virtual void nativeGenerate(int16_t *frame) = 0; 76 | virtual void resampledGenerate(int32_t *frame) = 0; 77 | 78 | virtual void generate(int16_t *output, size_t frames) = 0; 79 | virtual void generateAndMix(int16_t *output, size_t frames) = 0; 80 | virtual void generate32(int32_t *output, size_t frames) = 0; 81 | virtual void generateAndMix32(int32_t *output, size_t frames) = 0; 82 | 83 | virtual const char* emulatorName() = 0; 84 | virtual ChipType chipType() = 0; 85 | /** 86 | * @brief Does emulator has the per-channel full-panning extension? 87 | * @return true if emulator has this extension, false if emulator has only original behaviour 88 | */ 89 | virtual bool hasFullPanning() = 0; 90 | private: 91 | OPLChipBase(const OPLChipBase &c); 92 | OPLChipBase &operator=(const OPLChipBase &c); 93 | }; 94 | 95 | // A base class providing F-bounded generic and efficient implementations, 96 | // supporting resampling of chip outputs 97 | template 98 | class OPLChipBaseT : public OPLChipBase 99 | { 100 | public: 101 | OPLChipBaseT(); 102 | virtual ~OPLChipBaseT(); 103 | 104 | bool isRunningAtPcmRate() const override; 105 | bool setRunningAtPcmRate(bool r) override; 106 | #if defined(ADLMIDI_AUDIO_TICK_HANDLER) 107 | void setAudioTickHandlerInstance(void *instance); 108 | #endif 109 | 110 | virtual void setRate(uint32_t rate) override; 111 | uint32_t effectiveRate() const override; 112 | virtual void reset() override; 113 | void generate(int16_t *output, size_t frames) override; 114 | void generateAndMix(int16_t *output, size_t frames) override; 115 | void generate32(int32_t *output, size_t frames) override; 116 | void generateAndMix32(int32_t *output, size_t frames) override; 117 | private: 118 | bool m_runningAtPcmRate; 119 | #if defined(ADLMIDI_AUDIO_TICK_HANDLER) 120 | void *m_audioTickHandlerInstance; 121 | #endif 122 | void nativeTick(int16_t *frame); 123 | void setupResampler(uint32_t rate); 124 | void resetResampler(); 125 | void resampledGenerate(int32_t *output); 126 | #if defined(ADLMIDI_ENABLE_HQ_RESAMPLER) 127 | VResampler *m_resampler; 128 | #else 129 | int32_t m_oldsamples[2]; 130 | int32_t m_samples[2]; 131 | int32_t m_samplecnt; 132 | int32_t m_rateratio; 133 | enum { rsm_frac = 10 }; 134 | #endif 135 | // amplitude scale factors in and out of resampler, varying for chips; 136 | // values are OK to "redefine", the static polymorphism will accept it. 137 | enum { resamplerPreAmplify = 1, resamplerPostAttenuate = 1 }; 138 | }; 139 | 140 | // A base class which provides frame-by-frame interfaces on emulations which 141 | // don't have a routine for it. It produces outputs in fixed size buffers. 142 | // Fast register updates will suffer some latency because of buffering. 143 | template 144 | class OPLChipBaseBufferedT : public OPLChipBaseT 145 | { 146 | public: 147 | OPLChipBaseBufferedT() 148 | : OPLChipBaseT(), m_bufferIndex(0) {} 149 | virtual ~OPLChipBaseBufferedT() 150 | {} 151 | public: 152 | void reset() override; 153 | void nativeGenerate(int16_t *frame) override; 154 | protected: 155 | virtual void nativeGenerateN(int16_t *output, size_t frames) = 0; 156 | private: 157 | unsigned m_bufferIndex; 158 | int16_t m_buffer[2 * Buffer]; 159 | }; 160 | 161 | #include "opl_chip_base.tcc" 162 | 163 | #endif // ONP_CHIP_BASE_H 164 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/opl_serial_port.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | 22 | #ifdef ENABLE_HW_OPL_SERIAL_PORT 23 | 24 | #include "opl_serial_port.h" 25 | #include "opl_serial_misc.h" 26 | 27 | 28 | static size_t retrowave_protocol_serial_pack(const uint8_t *buf_in, size_t len_in, uint8_t *buf_out) 29 | { 30 | size_t in_cursor = 0; 31 | size_t out_cursor = 0; 32 | 33 | buf_out[out_cursor] = 0x00; 34 | out_cursor += 1; 35 | 36 | uint8_t shift_count = 0; 37 | 38 | while(in_cursor < len_in) 39 | { 40 | uint8_t cur_byte_out = buf_in[in_cursor] >> shift_count; 41 | if(in_cursor > 0) 42 | cur_byte_out |= (buf_in[in_cursor - 1] << (8 - shift_count)); 43 | 44 | cur_byte_out |= 0x01; 45 | buf_out[out_cursor] = cur_byte_out; 46 | 47 | shift_count += 1; 48 | in_cursor += 1; 49 | out_cursor += 1; 50 | if(shift_count > 7) 51 | { 52 | shift_count = 0; 53 | in_cursor -= 1; 54 | } 55 | } 56 | 57 | if(shift_count) 58 | { 59 | buf_out[out_cursor] = buf_in[in_cursor - 1] << (8 - shift_count); 60 | buf_out[out_cursor] |= 0x01; 61 | out_cursor += 1; 62 | } 63 | 64 | buf_out[out_cursor] = 0x02; 65 | out_cursor += 1; 66 | 67 | return out_cursor; 68 | } 69 | 70 | OPL_SerialPort::OPL_SerialPort() 71 | : m_port(NULL), m_protocol(ProtocolUnknown) 72 | {} 73 | 74 | OPL_SerialPort::~OPL_SerialPort() 75 | { 76 | delete m_port; 77 | m_port = NULL; 78 | } 79 | 80 | bool OPL_SerialPort::connectPort(const std::string& name, unsigned baudRate, unsigned protocol) 81 | { 82 | delete m_port; 83 | m_port = NULL; 84 | 85 | // ensure audio thread reads protocol atomically and in order, 86 | // so chipType() will be correct after the port is live 87 | m_protocol = protocol; 88 | 89 | // QSerialPort *port = m_port = new QSerialPort(name); 90 | // port->setBaudRate(baudRate); 91 | // return port->open(QSerialPort::WriteOnly); 92 | 93 | m_port = new ChipSerialPort; 94 | return m_port->open(name, baudRate); 95 | } 96 | 97 | bool OPL_SerialPort::hasFullPanning() 98 | { 99 | return false; 100 | } 101 | 102 | void OPL_SerialPort::writeReg(uint16_t addr, uint8_t data) 103 | { 104 | uint8_t sendBuffer[16]; 105 | ChipSerialPortBase *port = m_port; 106 | 107 | if(!port || !port->isOpen()) 108 | return; 109 | 110 | switch(m_protocol) 111 | { 112 | default: 113 | case ProtocolArduinoOPL2: 114 | { 115 | if(addr >= 0x100) 116 | break; 117 | sendBuffer[0] = (uint8_t)addr; 118 | sendBuffer[1] = (uint8_t)data; 119 | port->write(sendBuffer, 2); 120 | break; 121 | } 122 | case ProtocolNukeYktOPL3: 123 | { 124 | sendBuffer[0] = (addr >> 6) | 0x80; 125 | sendBuffer[1] = ((addr & 0x3f) << 1) | (data >> 7); 126 | sendBuffer[2] = (data & 0x7f); 127 | port->write(sendBuffer, 3); 128 | break; 129 | } 130 | case ProtocolRetroWaveOPL3: 131 | { 132 | bool port1 = (addr & 0x100) != 0; 133 | uint8_t buf[8] = 134 | { 135 | static_cast(0x21 << 1), 0x12, 136 | static_cast(port1 ? 0xe5 : 0xe1), static_cast(addr & 0xff), 137 | static_cast(port1 ? 0xe7 : 0xe3), static_cast(data), 138 | 0xfb, static_cast(data) 139 | }; 140 | size_t packed_len = retrowave_protocol_serial_pack(buf, sizeof(buf), sendBuffer); 141 | port->write(sendBuffer, packed_len); 142 | break; 143 | } 144 | } 145 | } 146 | 147 | void OPL_SerialPort::nativeGenerate(int16_t *frame) 148 | { 149 | frame[0] = 0; 150 | frame[1] = 0; 151 | } 152 | 153 | const char *OPL_SerialPort::emulatorName() 154 | { 155 | return "OPL Serial Port Driver"; 156 | } 157 | 158 | OPLChipBase::ChipType OPL_SerialPort::chipType() 159 | { 160 | switch(m_protocol) 161 | { 162 | default: 163 | case ProtocolArduinoOPL2: 164 | return OPLChipBase::CHIPTYPE_OPL2; 165 | case ProtocolNukeYktOPL3: 166 | case ProtocolRetroWaveOPL3: 167 | return OPLChipBase::CHIPTYPE_OPL3; 168 | } 169 | } 170 | 171 | #endif // ENABLE_HW_OPL_SERIAL_PORT 172 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/opl_serial_port.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | 22 | #ifndef OPL_SERIAL_PORT_H 23 | #define OPL_SERIAL_PORT_H 24 | 25 | #ifdef ENABLE_HW_OPL_SERIAL_PORT 26 | 27 | #include 28 | #include "opl_chip_base.h" 29 | 30 | class ChipSerialPortBase; 31 | 32 | class OPL_SerialPort : public OPLChipBaseT 33 | { 34 | public: 35 | OPL_SerialPort(); 36 | virtual ~OPL_SerialPort() override; 37 | 38 | enum Protocol 39 | { 40 | ProtocolUnknown, 41 | ProtocolArduinoOPL2, 42 | ProtocolNukeYktOPL3, 43 | ProtocolRetroWaveOPL3 44 | }; 45 | 46 | bool connectPort(const std::string &name, unsigned baudRate, unsigned protocol); 47 | 48 | bool canRunAtPcmRate() const override { return false; } 49 | void setRate(uint32_t /*rate*/) override {} 50 | void reset() override {} 51 | void writeReg(uint16_t addr, uint8_t data) override; 52 | void nativePreGenerate() override {} 53 | void nativePostGenerate() override {} 54 | void nativeGenerate(int16_t *frame) override; 55 | const char *emulatorName() override; 56 | ChipType chipType() override; 57 | bool hasFullPanning() override; 58 | 59 | private: 60 | ChipSerialPortBase *m_port; 61 | int m_protocol; 62 | }; 63 | 64 | #endif // ENABLE_HW_OPL_SERIAL_PORT 65 | 66 | #endif // OPL_SERIAL_PORT_H 67 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ym3812_lle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "ym3812_lle.h" 22 | #include "ym3812_lle/nuked_fmopl2.h" 23 | #include "ym3812_lle/nopl2.h" 24 | #include 25 | 26 | Ym3812LLEOPL2::Ym3812LLEOPL2() : 27 | OPLChipBaseT() 28 | { 29 | m_chip = nopl2_init(14318182, m_rate); 30 | setRate(m_rate); 31 | } 32 | 33 | Ym3812LLEOPL2::~Ym3812LLEOPL2() 34 | { 35 | fmopl2_t *chip_r = reinterpret_cast(m_chip); 36 | nopl2_shutdown(chip_r); 37 | } 38 | 39 | void Ym3812LLEOPL2::setRate(uint32_t rate) 40 | { 41 | OPLChipBaseT::setRate(rate); 42 | nopl2_set_rate(m_chip, 14318182, rate); 43 | } 44 | 45 | void Ym3812LLEOPL2::reset() 46 | { 47 | OPLChipBaseT::reset(); 48 | nopl2_reset(m_chip); 49 | } 50 | 51 | void Ym3812LLEOPL2::writeReg(uint16_t addr, uint8_t data) 52 | { 53 | nopl2_write(m_chip, 2 * ((addr >> 8) & 3), addr); 54 | nopl2_write(m_chip, 1, data); 55 | } 56 | 57 | void Ym3812LLEOPL2::writePan(uint16_t addr, uint8_t data) 58 | { 59 | (void)addr; 60 | (void)data; 61 | // Uninmplemented 62 | } 63 | 64 | void Ym3812LLEOPL2::nativeGenerate(int16_t *frame) 65 | { 66 | nopl2_getsample_one_native(m_chip, frame); 67 | } 68 | 69 | const char *Ym3812LLEOPL2::emulatorName() 70 | { 71 | return "YM3812-LLE OPL2"; 72 | } 73 | 74 | bool Ym3812LLEOPL2::hasFullPanning() 75 | { 76 | return false; 77 | } 78 | 79 | OPLChipBase::ChipType Ym3812LLEOPL2::chipType() 80 | { 81 | return CHIPTYPE_OPL2; 82 | } 83 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ym3812_lle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef YM3812LLE_OPL3_H 22 | #define YM3812LLE_OPL3_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class Ym3812LLEOPL2 final : public OPLChipBaseT 27 | { 28 | void *m_chip; 29 | public: 30 | Ym3812LLEOPL2(); 31 | ~Ym3812LLEOPL2() override; 32 | 33 | bool canRunAtPcmRate() const override { return false; } 34 | void setRate(uint32_t rate) override; 35 | void reset() override; 36 | void writeReg(uint16_t addr, uint8_t data) override; 37 | void writePan(uint16_t addr, uint8_t data) override; 38 | void nativePreGenerate() override {} 39 | void nativePostGenerate() override {} 40 | void nativeGenerate(int16_t *frame) override; 41 | const char *emulatorName() override; 42 | ChipType chipType() override; 43 | bool hasFullPanning() override; 44 | }; 45 | 46 | #endif // YM3812LLE_OPL3_H 47 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ym3812_lle/nopl2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 nukeykt 3 | * 4 | * This file is part of YM3812-LLE. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * YM3812 emulator 17 | * Thanks: 18 | * Travis Goodspeed: 19 | * YM3812 decap and die shot 20 | * 21 | */ 22 | 23 | #pragma once 24 | #ifndef NOPL2_H 25 | #define NOPL2_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | void *nopl2_init(int clock, int samplerate); 32 | void nopl2_set_rate(void *chip, int clock, int samplerate); 33 | void nopl2_shutdown(void *chip); 34 | void nopl2_reset(void *chip); 35 | 36 | void nopl2_getsample(void *chip, short *sndptr, int numsamples); 37 | void nopl2_getsample_one_native(void *chip, short *sndptr); 38 | 39 | void nopl2_write(void *chip, int port, int val); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* NOPL2_H */ 46 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ymf262_lle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "ymf262_lle.h" 22 | #include "ymf262_lle/nuked_fmopl3.h" 23 | #include "ymf262_lle/nopl3.h" 24 | #include 25 | 26 | Ymf262LLEOPL3::Ymf262LLEOPL3() : 27 | OPLChipBaseT() 28 | { 29 | m_chip = nopl3_init(14318182, m_rate); 30 | setRate(m_rate); 31 | } 32 | 33 | Ymf262LLEOPL3::~Ymf262LLEOPL3() 34 | { 35 | fmopl3_t *chip_r = reinterpret_cast(m_chip); 36 | nopl3_shutdown(chip_r); 37 | } 38 | 39 | void Ymf262LLEOPL3::setRate(uint32_t rate) 40 | { 41 | OPLChipBaseT::setRate(rate); 42 | nopl3_set_rate(m_chip, 14318182, rate); 43 | } 44 | 45 | void Ymf262LLEOPL3::reset() 46 | { 47 | OPLChipBaseT::reset(); 48 | nopl3_reset(m_chip); 49 | } 50 | 51 | void Ymf262LLEOPL3::writeReg(uint16_t addr, uint8_t data) 52 | { 53 | nopl3_write(m_chip, 2 * ((addr >> 8) & 3), addr); 54 | nopl3_write(m_chip, 1, data); 55 | } 56 | 57 | void Ymf262LLEOPL3::writePan(uint16_t addr, uint8_t data) 58 | { 59 | (void)addr; 60 | (void)data; 61 | // Uninmplemented 62 | } 63 | 64 | void Ymf262LLEOPL3::nativeGenerate(int16_t *frame) 65 | { 66 | nopl3_getsample_one_native(m_chip, frame); 67 | } 68 | 69 | const char *Ymf262LLEOPL3::emulatorName() 70 | { 71 | return "YMF262-LLE OPL3"; 72 | } 73 | 74 | bool Ymf262LLEOPL3::hasFullPanning() 75 | { 76 | return false; 77 | } 78 | 79 | OPLChipBase::ChipType Ymf262LLEOPL3::chipType() 80 | { 81 | return CHIPTYPE_OPL3; 82 | } 83 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ymf262_lle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef YMF262LLE_OPL3_H 22 | #define YMF262LLE_OPL3_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class Ymf262LLEOPL3 final : public OPLChipBaseT 27 | { 28 | void *m_chip; 29 | public: 30 | Ymf262LLEOPL3(); 31 | ~Ymf262LLEOPL3() override; 32 | 33 | bool canRunAtPcmRate() const override { return false; } 34 | void setRate(uint32_t rate) override; 35 | void reset() override; 36 | void writeReg(uint16_t addr, uint8_t data) override; 37 | void writePan(uint16_t addr, uint8_t data) override; 38 | void nativePreGenerate() override {} 39 | void nativePostGenerate() override {} 40 | void nativeGenerate(int16_t *frame) override; 41 | const char *emulatorName() override; 42 | ChipType chipType() override; 43 | bool hasFullPanning() override; 44 | }; 45 | 46 | #endif // YMF262LLE_OPL3_H 47 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ymf262_lle/Readme.md: -------------------------------------------------------------------------------- 1 | # YMF262-LLE 2 | 3 | Yamaha YMF262 (OPL3) emulator using YMF262 die shot. 4 | 5 | Special thanks to John McMaster for decapping YMF262. 6 | 7 | https://siliconpr0n.org/map/yamaha/ymf262-m/ 8 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ymf262_lle/nopl3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 nukeykt 3 | * 4 | * This file is part of YMF262-LLE. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * YMF262 emulator 17 | * Thanks: 18 | * John McMaster (siliconpr0n.org): 19 | * YMF262 decap and die shot 20 | * 21 | */ 22 | 23 | #pragma once 24 | #ifndef NOPL3_H 25 | #define NOPL3_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | void *nopl3_init(int clock, int samplerate); 32 | void nopl3_set_rate(void *chip, int clock, int samplerate); 33 | void nopl3_shutdown(void *chip); 34 | void nopl3_reset(void *chip); 35 | 36 | void nopl3_getsample(void *chip, short *sndptr, int numsamples); 37 | void nopl3_getsample_one_native(void *chip, short *sndptr); 38 | 39 | void nopl3_write(void *chip, int port, int val); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* NOPL3_H */ 46 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ymfm/ymfm_misc.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License 2 | // 3 | // Copyright (c) 2021, Aaron Giles 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // 3. Neither the name of the copyright holder nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include "ymfm_misc.h" 32 | 33 | namespace ymfm 34 | { 35 | 36 | //********************************************************* 37 | // YM2149 38 | //********************************************************* 39 | 40 | //------------------------------------------------- 41 | // ym2149 - constructor 42 | //------------------------------------------------- 43 | 44 | ym2149::ym2149(ymfm_interface &intf) : 45 | m_address(0), 46 | m_ssg(intf) 47 | { 48 | } 49 | 50 | 51 | //------------------------------------------------- 52 | // reset - reset the system 53 | //------------------------------------------------- 54 | 55 | void ym2149::reset() 56 | { 57 | // reset the engines 58 | m_ssg.reset(); 59 | } 60 | 61 | 62 | //------------------------------------------------- 63 | // save_restore - save or restore the data 64 | //------------------------------------------------- 65 | 66 | void ym2149::save_restore(ymfm_saved_state &state) 67 | { 68 | state.save_restore(m_address); 69 | m_ssg.save_restore(state); 70 | } 71 | 72 | 73 | //------------------------------------------------- 74 | // read_data - read the data register 75 | //------------------------------------------------- 76 | 77 | uint8_t ym2149::read_data() 78 | { 79 | return m_ssg.read(m_address & 0x0f); 80 | } 81 | 82 | 83 | //------------------------------------------------- 84 | // read - handle a read from the device 85 | //------------------------------------------------- 86 | 87 | uint8_t ym2149::read(uint32_t offset) 88 | { 89 | uint8_t result = 0xff; 90 | switch (offset & 3) // BC2,BC1 91 | { 92 | case 0: // inactive 93 | break; 94 | 95 | case 1: // address 96 | break; 97 | 98 | case 2: // inactive 99 | break; 100 | 101 | case 3: // read 102 | result = read_data(); 103 | break; 104 | } 105 | return result; 106 | } 107 | 108 | 109 | //------------------------------------------------- 110 | // write_address - handle a write to the address 111 | // register 112 | //------------------------------------------------- 113 | 114 | void ym2149::write_address(uint8_t data) 115 | { 116 | // just set the address 117 | m_address = data; 118 | } 119 | 120 | 121 | //------------------------------------------------- 122 | // write - handle a write to the register 123 | // interface 124 | //------------------------------------------------- 125 | 126 | void ym2149::write_data(uint8_t data) 127 | { 128 | m_ssg.write(m_address & 0x0f, data); 129 | } 130 | 131 | 132 | //------------------------------------------------- 133 | // write - handle a write to the register 134 | // interface 135 | //------------------------------------------------- 136 | 137 | void ym2149::write(uint32_t offset, uint8_t data) 138 | { 139 | switch (offset & 3) // BC2,BC1 140 | { 141 | case 0: // address 142 | write_address(data); 143 | break; 144 | 145 | case 1: // inactive 146 | break; 147 | 148 | case 2: // write 149 | write_data(data); 150 | break; 151 | 152 | case 3: // address 153 | write_address(data); 154 | break; 155 | } 156 | } 157 | 158 | 159 | //------------------------------------------------- 160 | // generate - generate samples of SSG sound 161 | //------------------------------------------------- 162 | 163 | void ym2149::generate(output_data *output, uint32_t numsamples) 164 | { 165 | for (uint32_t samp = 0; samp < numsamples; samp++, output++) 166 | { 167 | // clock the SSG 168 | m_ssg.clock(); 169 | 170 | // YM2149 keeps the three SSG outputs independent 171 | m_ssg.output(*output); 172 | } 173 | } 174 | 175 | } 176 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ymfm/ymfm_misc.h: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License 2 | // 3 | // Copyright (c) 2021, Aaron Giles 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // 3. Neither the name of the copyright holder nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef YMFM_MISC_H 32 | #define YMFM_MISC_H 33 | 34 | #pragma once 35 | 36 | #include "ymfm.h" 37 | #include "ymfm_adpcm.h" 38 | #include "ymfm_ssg.h" 39 | 40 | namespace ymfm 41 | { 42 | 43 | //********************************************************* 44 | // SSG IMPLEMENTATION CLASSES 45 | //********************************************************* 46 | 47 | // ======================> ym2149 48 | 49 | // ym2149 is just an SSG with no FM part, but we expose FM-like parts so that it 50 | // integrates smoothly with everything else; they just don't do anything 51 | class ym2149 52 | { 53 | public: 54 | static constexpr uint32_t OUTPUTS = ssg_engine::OUTPUTS; 55 | static constexpr uint32_t SSG_OUTPUTS = ssg_engine::OUTPUTS; 56 | using output_data = ymfm_output; 57 | 58 | // constructor 59 | ym2149(ymfm_interface &intf); 60 | 61 | // configuration 62 | void ssg_override(ssg_override &intf) { m_ssg.override(intf); } 63 | 64 | // reset 65 | void reset(); 66 | 67 | // save/restore 68 | void save_restore(ymfm_saved_state &state); 69 | 70 | // pass-through helpers 71 | uint32_t sample_rate(uint32_t input_clock) const { return input_clock / ssg_engine::CLOCK_DIVIDER / 8; } 72 | 73 | // read access 74 | uint8_t read_data(); 75 | uint8_t read(uint32_t offset); 76 | 77 | // write access 78 | void write_address(uint8_t data); 79 | void write_data(uint8_t data); 80 | void write(uint32_t offset, uint8_t data); 81 | 82 | // generate one sample of sound 83 | void generate(output_data *output, uint32_t numsamples = 1); 84 | 85 | protected: 86 | // internal state 87 | uint8_t m_address; // address register 88 | ssg_engine m_ssg; // SSG engine 89 | }; 90 | 91 | } 92 | 93 | #endif // YMFM_MISC_H 94 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ymfm_opl2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (ym3812) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "ymfm_opl2.h" 22 | #include "ymfm/ymfm_opl.h" 23 | #include 24 | 25 | YmFmOPL2::YmFmOPL2() : 26 | OPLChipBaseT(), 27 | m_headPos(0), 28 | m_tailPos(0), 29 | m_queueCount(0) 30 | { 31 | ymfm::ymfm_interface* intf = new ymfm::ymfm_interface; 32 | m_intf = intf; 33 | m_chip = new ymfm::ym3812(*intf); 34 | YmFmOPL2::setRate(m_rate); 35 | } 36 | 37 | YmFmOPL2::~YmFmOPL2() 38 | { 39 | ymfm::ym3812 *chip_r = reinterpret_cast(m_chip); 40 | ymfm::ymfm_interface *intf_r = reinterpret_cast(m_intf); 41 | delete chip_r; 42 | delete intf_r; 43 | } 44 | 45 | void YmFmOPL2::setRate(uint32_t rate) 46 | { 47 | OPLChipBaseT::setRate(rate); 48 | ymfm::ym3812 *chip_r = reinterpret_cast(m_chip); 49 | chip_r->reset(); 50 | } 51 | 52 | void YmFmOPL2::reset() 53 | { 54 | OPLChipBaseT::reset(); 55 | ymfm::ym3812 *chip_r = reinterpret_cast(m_chip); 56 | chip_r->reset(); 57 | } 58 | 59 | void YmFmOPL2::writeReg(uint16_t addr, uint8_t data) 60 | { 61 | Reg &back = m_queue[m_headPos++]; 62 | back.addr = addr; 63 | back.data = data; 64 | 65 | if(m_headPos >= c_queueSize) 66 | m_headPos = 0; 67 | 68 | ++m_queueCount; 69 | } 70 | 71 | void YmFmOPL2::nativeGenerate(int16_t *frame) 72 | { 73 | ymfm::ym3812 *chip_r = reinterpret_cast(m_chip); 74 | ymfm::ym3812::output_data frames_i; 75 | 76 | uint32_t addr1 = 0xffff, addr2 = 0xffff; 77 | uint8_t data1 = 0, data2 = 0; 78 | 79 | // see if there is data to be written; if so, extract it and dequeue 80 | if(m_queueCount > 0) 81 | { 82 | const Reg &front = m_queue[m_tailPos++]; 83 | 84 | if(m_tailPos >= c_queueSize) 85 | m_tailPos = 0; 86 | --m_queueCount; 87 | 88 | addr1 = 0 + 2 * ((front.addr >> 8) & 3); 89 | data1 = front.addr & 0xff; 90 | addr2 = addr1 + 1; 91 | data2 = front.data; 92 | } 93 | 94 | // write to the chip 95 | if(addr1 != 0xffff) 96 | { 97 | chip_r->write(addr1, data1); 98 | chip_r->write(addr2, data2); 99 | } 100 | 101 | chip_r->generate(&frames_i); 102 | frame[0] = static_cast(ymfm::clamp(frames_i.data[0], -32768, 32767)); 103 | frame[1] = frame[0]; 104 | } 105 | 106 | const char *YmFmOPL2::emulatorName() 107 | { 108 | return "YMFM OPL2"; 109 | } 110 | 111 | bool YmFmOPL2::hasFullPanning() 112 | { 113 | return false; 114 | } 115 | 116 | OPLChipBase::ChipType YmFmOPL2::chipType() 117 | { 118 | return CHIPTYPE_OPL2; 119 | } 120 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ymfm_opl2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef YMFM_OPL2_H 22 | #define YMFM_OPL2_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class YmFmOPL2 final : public OPLChipBaseT 27 | { 28 | void *m_chip; 29 | void *m_intf; 30 | 31 | static const size_t c_queueSize = 500; 32 | 33 | struct Reg 34 | { 35 | uint32_t addr; 36 | uint8_t data; 37 | }; 38 | 39 | Reg m_queue[c_queueSize]; 40 | size_t m_headPos; 41 | size_t m_tailPos; 42 | long m_queueCount; 43 | 44 | public: 45 | YmFmOPL2(); 46 | ~YmFmOPL2() override; 47 | 48 | bool canRunAtPcmRate() const override { return false; } 49 | void setRate(uint32_t rate) override; 50 | void reset() override; 51 | void writeReg(uint16_t addr, uint8_t data) override; 52 | void nativePreGenerate() override {} 53 | void nativePostGenerate() override {} 54 | void nativeGenerate(int16_t *frame) override; 55 | const char *emulatorName() override; 56 | ChipType chipType() override; 57 | bool hasFullPanning() override; 58 | }; 59 | 60 | #endif // YMFM_OPL2_H 61 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ymfm_opl3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "ymfm_opl3.h" 22 | #include "ymfm/ymfm_opl.h" 23 | #include 24 | 25 | YmFmOPL3::YmFmOPL3() : 26 | OPLChipBaseT(), 27 | m_headPos(0), 28 | m_tailPos(0), 29 | m_queueCount(0) 30 | { 31 | ymfm::ymfm_interface* intf = new ymfm::ymfm_interface; 32 | m_intf = intf; 33 | m_chip = new ymfm::ymf262(*intf); 34 | YmFmOPL3::setRate(m_rate); 35 | } 36 | 37 | YmFmOPL3::~YmFmOPL3() 38 | { 39 | ymfm::ymf262 *chip_r = reinterpret_cast(m_chip); 40 | ymfm::ymfm_interface *intf_r = reinterpret_cast(m_intf); 41 | delete chip_r; 42 | delete intf_r; 43 | } 44 | 45 | void YmFmOPL3::setRate(uint32_t rate) 46 | { 47 | OPLChipBaseT::setRate(rate); 48 | ymfm::ymf262 *chip_r = reinterpret_cast(m_chip); 49 | chip_r->reset(); 50 | } 51 | 52 | void YmFmOPL3::reset() 53 | { 54 | OPLChipBaseT::reset(); 55 | ymfm::ymf262 *chip_r = reinterpret_cast(m_chip); 56 | chip_r->reset(); 57 | } 58 | 59 | void YmFmOPL3::writeReg(uint16_t addr, uint8_t data) 60 | { 61 | Reg &back = m_queue[m_headPos++]; 62 | back.addr = addr; 63 | back.data = data; 64 | 65 | if(m_headPos >= c_queueSize) 66 | m_headPos = 0; 67 | 68 | ++m_queueCount; 69 | } 70 | 71 | void YmFmOPL3::nativeGenerate(int16_t *frame) 72 | { 73 | ymfm::ymf262 *chip_r = reinterpret_cast(m_chip); 74 | ymfm::ymf262::output_data frames_i; 75 | 76 | uint32_t addr1 = 0xffff, addr2 = 0xffff; 77 | uint8_t data1 = 0, data2 = 0; 78 | 79 | // see if there is data to be written; if so, extract it and dequeue 80 | if(m_queueCount > 0) 81 | { 82 | const Reg &front = m_queue[m_tailPos++]; 83 | 84 | if(m_tailPos >= c_queueSize) 85 | m_tailPos = 0; 86 | --m_queueCount; 87 | 88 | addr1 = 0 + 2 * ((front.addr >> 8) & 3); 89 | data1 = front.addr & 0xff; 90 | addr2 = addr1 + 1; 91 | data2 = front.data; 92 | } 93 | 94 | // write to the chip 95 | if(addr1 != 0xffff) 96 | { 97 | chip_r->write(addr1, data1); 98 | chip_r->write(addr2, data2); 99 | } 100 | 101 | chip_r->generate(&frames_i); 102 | frame[0] = static_cast(ymfm::clamp(frames_i.data[0] / 2, -32768, 32767)); 103 | frame[1] = static_cast(ymfm::clamp(frames_i.data[1] / 2, -32768, 32767)); 104 | } 105 | 106 | const char *YmFmOPL3::emulatorName() 107 | { 108 | return "YMFM OPL3"; 109 | } 110 | 111 | OPLChipBase::ChipType YmFmOPL3::chipType() 112 | { 113 | return CHIPTYPE_OPL3; 114 | } 115 | 116 | bool YmFmOPL3::hasFullPanning() 117 | { 118 | return false; 119 | } 120 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/chips/ymfm_opl3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interfaces over Yamaha OPL3 (YMF262) chip emulators 3 | * 4 | * Copyright (c) 2017-2025 Vitaly Novichkov (Wohlstand) 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef YMFM_OPL3_H 22 | #define YMFM_OPL3_H 23 | 24 | #include "opl_chip_base.h" 25 | 26 | class YmFmOPL3 final : public OPLChipBaseT 27 | { 28 | void *m_chip; 29 | void *m_intf; 30 | 31 | static const size_t c_queueSize = 500; 32 | 33 | struct Reg 34 | { 35 | uint32_t addr; 36 | uint8_t data; 37 | }; 38 | 39 | Reg m_queue[c_queueSize]; 40 | size_t m_headPos; 41 | size_t m_tailPos; 42 | long m_queueCount; 43 | 44 | public: 45 | YmFmOPL3(); 46 | ~YmFmOPL3() override; 47 | 48 | bool canRunAtPcmRate() const override { return false; } 49 | void setRate(uint32_t rate) override; 50 | void reset() override; 51 | void writeReg(uint16_t addr, uint8_t data) override; 52 | void nativePreGenerate() override {} 53 | void nativePostGenerate() override {} 54 | void nativeGenerate(int16_t *frame) override; 55 | const char *emulatorName() override; 56 | ChipType chipType() override; 57 | bool hasFullPanning() override; 58 | }; 59 | 60 | #endif // YMFM_OPL3_H 61 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/oplinst.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation 3 | * 4 | * Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma 5 | * ADLMIDI Library API: Copyright (c) 2015-2025 Vitaly Novichkov 6 | * 7 | * Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation: 8 | * http://iki.fi/bisqwit/source/adlmidi.html 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | #ifndef OPLINST_H 25 | #define OPLINST_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #pragma pack(push, 1) 32 | #define OPLINST_BYTE_COMPARABLE(T) \ 33 | inline bool operator==(const T &a, const T &b) \ 34 | { return !memcmp(&a, &b, sizeof(T)); } \ 35 | inline bool operator!=(const T &a, const T &b) \ 36 | { return !operator==(a, b); } 37 | 38 | /** 39 | * @brief OPL3 Operator data for single tumbre 40 | */ 41 | struct OplTimbre 42 | { 43 | //! WaveForm, Sustain/Release, AttackDecay, and AM/VIB/EG/KSR/F-Mult settings 44 | uint32_t modulator_E862, carrier_E862; 45 | //! KSL/attenuation settings 46 | uint8_t modulator_40, carrier_40; 47 | //! Feedback/connection bits for the channel 48 | uint8_t feedconn; 49 | //! Semi-tone offset 50 | int8_t noteOffset; 51 | }; 52 | OPLINST_BYTE_COMPARABLE(struct OplTimbre) 53 | 54 | 55 | enum { OPLNoteOnMaxTime = 40000 }; 56 | 57 | 58 | /** 59 | * @brief Instrument data with operators included 60 | */ 61 | struct OplInstMeta 62 | { 63 | enum 64 | { 65 | Flag_Pseudo4op = 0x01, 66 | Flag_NoSound = 0x02, 67 | Flag_Real4op = 0x04 68 | }; 69 | 70 | enum 71 | { 72 | Flag_RM_BassDrum = 0x08, 73 | Flag_RM_Snare = 0x10, 74 | Flag_RM_TomTom = 0x18, 75 | Flag_RM_Cymbal = 0x20, 76 | Flag_RM_HiHat = 0x28, 77 | Mask_RhythmMode = 0x38 78 | }; 79 | 80 | //! Operator data 81 | OplTimbre op[2]; 82 | //! Fixed note for drum instruments 83 | uint8_t drumTone; 84 | //! Instrument flags 85 | uint8_t flags; 86 | //! Number of milliseconds it produces sound while key on 87 | uint16_t soundKeyOnMs; 88 | //! Number of milliseconds it produces sound while releasing after key off 89 | uint16_t soundKeyOffMs; 90 | //! MIDI velocity offset 91 | int8_t midiVelocityOffset; 92 | //! Second voice detune 93 | double voice2_fine_tune; 94 | }; 95 | OPLINST_BYTE_COMPARABLE(struct OplInstMeta) 96 | 97 | #undef OPLINST_BYTE_COMPARABLE 98 | #pragma pack(pop) 99 | 100 | /** 101 | * @brief Bank global setup 102 | */ 103 | struct OplBankSetup 104 | { 105 | int volumeModel; 106 | bool deepTremolo; 107 | bool deepVibrato; 108 | bool scaleModulators; 109 | bool mt32defaults; 110 | }; 111 | 112 | /** 113 | * @brief Convert external instrument to internal instrument 114 | */ 115 | void cvt_ADLI_to_FMIns(OplInstMeta &dst, const struct ADL_Instrument &src); 116 | 117 | /** 118 | * @brief Convert internal instrument to external instrument 119 | */ 120 | void cvt_FMIns_to_ADLI(struct ADL_Instrument &dst, const OplInstMeta &src); 121 | 122 | #endif // OPLINST_H 123 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/src/structures/pl_list.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Jean Pierre Cimalando 2018. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef PL_LIST_HPP 7 | #define PL_LIST_HPP 8 | 9 | #include 10 | #include 11 | 12 | /* 13 | pl_cell: the linked list cell 14 | */ 15 | template 16 | struct pl_cell; 17 | 18 | template 19 | struct pl_basic_cell 20 | { 21 | pl_cell *prev, *next; 22 | }; 23 | 24 | template 25 | struct pl_cell : pl_basic_cell 26 | { 27 | T value; 28 | }; 29 | 30 | /* 31 | pl_iterator: the linked list iterator 32 | */ 33 | template 34 | class pl_iterator 35 | { 36 | public: 37 | typedef std::bidirectional_iterator_tag iterator_category; 38 | typedef Cell value_type; 39 | typedef Cell &reference; 40 | typedef Cell *pointer; 41 | typedef std::ptrdiff_t difference_type; 42 | 43 | pl_iterator(Cell *cell = NULL); 44 | bool is_end() const; 45 | Cell &operator*() const; 46 | Cell *operator->() const; 47 | bool operator==(const pl_iterator &i) const; 48 | bool operator!=(const pl_iterator &i) const; 49 | pl_iterator &operator++(); 50 | pl_iterator operator++(int); 51 | pl_iterator &operator--(); 52 | pl_iterator operator--(int); 53 | 54 | private: 55 | Cell *cell_; 56 | }; 57 | 58 | /* 59 | pl_list: the preallocated linked list 60 | */ 61 | template 62 | class pl_list 63 | { 64 | public: 65 | typedef pl_cell value_type; 66 | typedef value_type *pointer; 67 | typedef value_type &reference; 68 | typedef const value_type *const_pointer; 69 | typedef const value_type &const_reference; 70 | typedef pl_iterator< pl_cell > iterator; 71 | typedef pl_iterator< const pl_cell > const_iterator; 72 | 73 | pl_list(std::size_t capacity = 0); 74 | ~pl_list(); 75 | 76 | struct external_storage_policy {}; 77 | pl_list(pl_cell *cells, std::size_t ncells, external_storage_policy); 78 | 79 | pl_list(const pl_list &other); 80 | pl_list &operator=(const pl_list &other); 81 | 82 | std::size_t size() const; 83 | std::size_t capacity() const; 84 | bool empty() const; 85 | 86 | iterator begin(); 87 | iterator end(); 88 | const_iterator begin() const; 89 | const_iterator end() const; 90 | 91 | void clear(); 92 | 93 | pl_cell &front(); 94 | const pl_cell &front() const; 95 | pl_cell &back(); 96 | const pl_cell &back() const; 97 | 98 | iterator insert(iterator pos, const T &x); 99 | iterator erase(iterator pos); 100 | void push_front(const T &x); 101 | void push_back(const T &x); 102 | void pop_front(); 103 | void pop_back(); 104 | 105 | iterator find(const T &x); 106 | const_iterator find(const T &x) const; 107 | template iterator find_if(const Pred &p); 108 | template const_iterator find_if(const Pred &p) const; 109 | 110 | private: 111 | // number of cells in the list 112 | std::size_t size_; 113 | // number of cells allocated 114 | std::size_t capacity_; 115 | // array of cells allocated 116 | pl_cell *cells_; 117 | // pointer to the head cell 118 | pl_cell *first_; 119 | // pointer to the next free cell 120 | pl_cell *free_; 121 | // value-less cell which terminates the linked list 122 | pl_basic_cell endcell_; 123 | // whether cell storage is allocated 124 | bool cells_allocd_; 125 | 126 | void initialize(std::size_t capacity, pl_cell *extcells = NULL); 127 | pl_cell *allocate(pl_cell *pos); 128 | void deallocate(pl_cell *cell); 129 | }; 130 | 131 | #include "pl_list.tcc" 132 | 133 | #endif // PL_LIST_HPP 134 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/cpp/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -Rfv include 4 | rm -Rfv src 5 | rm -v CMakeLists.txt 6 | rm -v libADLMIDIConfig.cmake.in 7 | 8 | cp -av /home/vitaly/_git_repos/libADLMIDI/include . 9 | cp -av /home/vitaly/_git_repos/libADLMIDI/src . 10 | cp -v /home/vitaly/_git_repos/libADLMIDI/CMakeLists.txt . 11 | cp -v /home/vitaly/_git_repos/libADLMIDI/libADLMIDIConfig.cmake.in . 12 | 13 | echo "Press any key..." 14 | read -n 1 15 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/java/ru/wohlsoft/adlmidiplayer/HardButtonReceiver.java: -------------------------------------------------------------------------------- 1 | package ru.wohlsoft.adlmidiplayer; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.util.Log; 7 | import android.view.KeyEvent; 8 | 9 | /** 10 | * Copyright 2011 Matthew Gaunt 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | * 25 | * NOTE: 26 | * This code has been briefly tested on a Nexus One running Android 27 | * version 2.2.2 and a G1 running version 1.6 28 | * 29 | * 30 | * @author Matthew Gaunt - http://www.gauntface.co.uk/ 31 | * 32 | */ 33 | 34 | public class HardButtonReceiver extends BroadcastReceiver 35 | { 36 | private final static String TAG = "gauntface"; 37 | 38 | private PlayerService mButtonListener = null; 39 | 40 | public HardButtonReceiver() { 41 | super(); 42 | } 43 | 44 | public HardButtonReceiver(PlayerService buttonListener) { 45 | super(); 46 | 47 | mButtonListener = buttonListener; 48 | } 49 | 50 | @Override 51 | public void onReceive(Context context, Intent intent) 52 | { 53 | Log.d(TAG, "HardButtonReceiver: Button press received"); 54 | if(mButtonListener != null) 55 | { 56 | /* 57 | * We abort the broadcast to prevent the event being passed down 58 | * to other apps (i.e. the Music app) 59 | */ 60 | abortBroadcast(); 61 | 62 | // Pull out the KeyEvent from the intent 63 | KeyEvent key = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); 64 | 65 | // This is just some example logic, you may want to change this for different behaviour 66 | if(key != null && key.getAction() == KeyEvent.ACTION_UP) 67 | { 68 | int keycode = key.getKeyCode(); 69 | 70 | // These are examples for detecting key presses on a Nexus One headset 71 | if(keycode == KeyEvent.KEYCODE_MEDIA_NEXT) 72 | { 73 | mButtonListener.onNextButtonPress(); 74 | } 75 | else if(keycode == KeyEvent.KEYCODE_MEDIA_PREVIOUS) 76 | { 77 | mButtonListener.onPrevButtonPress(); 78 | } 79 | else if(keycode == KeyEvent.KEYCODE_HEADSETHOOK) 80 | { 81 | mButtonListener.onPlayPauseButtonPress(); 82 | } 83 | } 84 | } 85 | } 86 | 87 | public interface HardButtonListener { 88 | void onPrevButtonPress(); 89 | void onNextButtonPress(); 90 | void onPlayPauseButtonPress(); 91 | } 92 | } -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/drawable-hdpi/ic_music_playing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/drawable-hdpi/ic_music_playing.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/drawable-mdpi/ic_music_playing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/drawable-mdpi/ic_music_playing.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/drawable-xhdpi/ic_music_playing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/drawable-xhdpi/ic_music_playing.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/drawable-xxhdpi/ic_music_playing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/drawable-xxhdpi/ic_music_playing.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/drawable-xxxhdpi/ic_music_playing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/drawable-xxxhdpi/ic_music_playing.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/drawable/ic_menu_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/drawable/ic_menu_back.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/drawable/ic_menu_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/drawable/ic_menu_home.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/ADLMIDI-Player/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/values-en/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ADLMIDI Player 4 | Music bank 5 | Deep Tremolo 6 | Deep Vibrato 7 | Open 8 | Play/Pause 9 | Quit 10 | Scalable modulation 11 | Total number of 4-op channels 12 | Number of emulated chips 13 | Restart 14 | Volume ranges model 15 | [Auto] 16 | Generic 17 | OPL3 Native 18 | DMX 19 | Apogee 20 | 9X 21 | Choose custom bank 22 | Use custom 23 | ]]> 24 | Full-panning stereo 25 | ]]> 26 | Gain factor 27 | Run at PCM Rate (Reduce CPU usage) 28 | OPL3 Emulator 29 | ]]> 30 | Auto Arpeggio 31 | Channel allocation mode 32 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/values-fr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Lecteur ADLMIDI 4 | Banque de timbres 5 | Trémolo augmenté 6 | Vibrato augmenté 7 | Ouvrir 8 | Lecture/Pause 9 | Quitter 10 | Modulation variable 11 | Nombre total de canaux 4-op 12 | Nombre de circuits émulés 13 | Redémarrer 14 | Modèle de volume 15 | [Auto] 16 | Générique 17 | Natif OPL3 18 | DMX 19 | Apogee 20 | 9X 21 | Choisir banque perso 22 | Utiliser le choix perso 23 | ]]> 24 | Panoramique stéréo étendue 25 | ]]> 26 | Facteur de Gain 27 | Calculer au taux PCM (charge processeur moindre) 28 | Émulateur OPL3 29 | ]]> 30 | Arpège automatique 31 | Mode d\'allocation des canaux 32 | 33 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Плеер ADLMIDI 4 | Муз. банк 5 | Усиленное тремоло 6 | Усиленное вибрато 7 | Открыть 8 | Воспр./Приост. 9 | Выйти 10 | Регулируемая модуляция 11 | Всего 4-х операторных каналов 12 | Число эмулируемых чипов 13 | Рестарт 14 | Модель диапазонов громкости 15 | [Авто] 16 | Общий 17 | Встроенная OPL3 18 | DMX 19 | Apogee 20 | 9X 21 | Отркыть свой банк 22 | Вкл. свой банк 23 | ]]> 24 | Полное стерео 25 | ]]> 26 | Фактор усиления 27 | Работа на PCM-частоте (Легче для ЦПУ) 28 | Эмулятор OPL3 29 | ]]> 30 | Авто-арпеджио 31 | Режим выборки каналов 32 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #CC8A86 4 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ADLMIDI Player 3 | Open 4 | Play/Pause 5 | Quit 6 | Music bank 7 | Deep Tremolo 8 | Deep Vibrato 9 | Scalable modulation 10 | Number of emulated chips 11 | Total number of 4-op channels 12 | Restart 13 | Volume ranges model 14 | [Auto] 15 | Generic 16 | OPL3 Native 17 | DMX 18 | Apogee 19 | 9X 20 | Choose custom bank 21 | Use custom 22 | ]]> 23 | - 24 | + 25 | Full-panning stereo 26 | ]]> 27 | Gain factor 28 | ++ 29 | -- 30 | Run at PCM Rate (Reduce CPU usage) 31 | OPL3 Emulator 32 | ]]> 33 | Auto Arpeggio 34 | Channel allocation mode 35 | 36 | -------------------------------------------------------------------------------- /ADLMIDI-Player/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Vitaly Novichkov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ADLMIDI-Player-Java 2 | Implementation of ADLMIDI based MIDI-player for Android 3 | 4 | It's a MIDI-player based on emulator of a Frequency Modulation chip Yamaha OPL3. This small MIDI-player made with using of [libADLMIDI](https://github.com/Wohlstand/libADLMIDI/) library - a fork of original ADLMIDI a console program implementation. 5 | 6 | # Key features 7 | 8 | * OPL3 emulation with four-operator mode support 9 | * FM patches from a number of known PC games, copied from files typical to AIL = Miles Sound System / DMX / HMI = Human Machine Interfaces / Creative IBK. 10 | * Stereo sound 11 | * Number of simulated OPL3 chips can be specified as 1-100 (maximum channels 1800!) 12 | * Pan (binary panning, i.e. left/right side on/off) 13 | * Pitch-bender with adjustable range 14 | * Vibrato that responds to RPN/NRPN parameters 15 | * Sustain (a.k.a. Pedal hold) and Sostenuto enable/disable 16 | * MIDI and RMI file support 17 | * Real-Time MIDI API support 18 | * loopStart / loopEnd tag support (Final Fantasy VII) 19 | * 111-th controller based loop start (RPG-Maker) 20 | * Use automatic arpeggio with chords to relieve channel pressure 21 | * Support for multiple concurrent MIDI synthesizers (per-track device/port select FF 09 message), can be used to overcome 16 channel limit 22 | * Support for playing Id-software Music File format (IMF) 23 | * Support for custom banks of [WOPL format](https://github.com/Wohlstand/OPL3BankEditor/blob/master/Specifications/WOPL-and-OPLI-Specification.txt) 24 | * Partial support for GS and XG standards (having more instruments than in one 128:128 GM set and ability to use multiple channels for percussion purposes, and a support for some GS/XG exclusive controllers) 25 | * CC74 "Brightness" affects a modulator scale (to simulate frequency cut-off on WT synths) 26 | * Portamento support (CC5, CC37, and CC65) 27 | * SysEx support that supports some generic, GS, and XG features 28 | * Full-panning stereo option (works for emulators only) 29 | 30 | # Download latest binary 31 | 32 | https://github.com/Wohlstand/ADLMIDI-Player-Java/releases 33 | 34 | # System requirements 35 | 36 | * Recommended to have powerful CPU: Emulation of OPL3 chip is a sound generation by formulas which requires requires operations. For example, application works almost fine on Samsung GT-I9300 which has quad-core Exynos 4212 CPU with 1400 Mhz. On slow CPUs it may lag, for example, on LG-E612 with MSM7225A Cortex A5 with 800 Mhz. 37 | * 4 MB free space 38 | 39 | # How to install 40 | 41 | * Put APK to your Android device 42 | * Check in settings that custom applications installations are allowed 43 | * Open APK via any file manager and confirm installation 44 | * Allow external storage reading (needed to open MIDI-files from phone memory and SD Card) 45 | 46 | # How to use 47 | 48 | * Use "Open" button to open file dialog and select any MIDI, RMI, KAR or IMF (Wolfinstein 3D) file 49 | * Setup any preferences (bank, tremolo, vibrato, number of emulated chips, etc.) 50 | * Press "Play/Pause" to start playing or press again to pause or resume 51 | * Press "Restart" to begin playing of music from begin (needed to apply changes of some settings) 52 | * Use "Open" again to select any other music file 53 | * You can switch another application or lock screen, music playing will work in background. 54 | 55 | # Tips 56 | 57 | * This application audio playback may lag on various devices, therefore you can reduce number of emulated chips 58 | * If you are using "4-operators" banks, you can increase number of 4-op channels into number of chips multiped to 6 (each OPL3 chip supports maximum 6 four-operator channels). Or simply use "" mode which will automatically choose count of necessary 4-operator channels in dependence on a bank. 59 | * Set number of four-operator channels into zero if you are using 2-operator banks (most of banks are 4-operators. Pseudo-four-operator banks are 2-operator banks with double-voice support) 60 | 61 | More detailed about playing MIDI with this application you also can find on [libADLMIDI library repo](https://github.com/Wohlstand/libADLMIDI/) 62 | 63 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | repositories { 4 | mavenCentral() 5 | maven { 6 | url 'https://maven.google.com/' 7 | name 'Google' 8 | } 9 | google() 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:8.2.2' 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | allprojects { 19 | repositories { 20 | mavenCentral() 21 | maven { 22 | url 'https://maven.google.com/' 23 | name 'Google' 24 | } 25 | } 26 | tasks.withType(JavaCompile) { 27 | options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" 28 | } 29 | } 30 | tasks.register('clean', Delete) { 31 | delete rootProject.buildDir 32 | } 33 | -------------------------------------------------------------------------------- /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 | android.defaults.buildfeatures.buildconfig=true 13 | android.enableJetifier=false 14 | android.nonFinalResIds=true 15 | android.nonTransitiveRClass=true 16 | android.useAndroidX=true 17 | org.gradle.jvmargs=-Xmx1536m 18 | 19 | # When configured, Gradle will run in incubating parallel mode. 20 | # This option should only be used with decoupled projects. More details, visit 21 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 22 | # org.gradle.parallel=true 23 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wohlstand/ADLMIDI-Player-Java/a2464336c9fe289e0094a6561c33049da60fb016/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Feb 02 15:14:45 MSK 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionSha256Sum=2ab88d6de2c23e6adae7363ae6e29cbdd2a709e992929b48b6530fd0c7133bd6 7 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip 8 | networkTimeout=10000 9 | validateDistributionUrl=true 10 | -------------------------------------------------------------------------------- /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 ':ADLMIDI-Player' 2 | --------------------------------------------------------------------------------