Commit 4e9d81d0 authored by Sandro Andrade's avatar Sandro Andrade
Browse files

Improve Android build system

Clone and build CSound for Android as part of Android build process
parent 93f30151
<?xml version="1.0"?>
<manifest package="org.kde.minuet" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.3.0" android:versionCode="5" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Minuet" android:icon="@drawable/minuet" android:theme="@style/MinuetTheme">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation"
android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="Minuet" android:screenOrientation="unspecified" android:launchMode="singleTop">
<?xml version='1.0' encoding='utf-8'?>
<manifest package="org.kde.minuet"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionName="0.3.0"
android:versionCode="5"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- %%INSERT_PERMISSIONS -->
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<!-- %%INSERT_FEATURES -->
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:anyDensity="true"
android:smallScreens="true"/>
<application android:hardwareAccelerated="true"
android:name="org.qtproject.qt5.android.bindings.QtApplication"
android:label="Minuet"
android:icon="@drawable/minuet"
android:theme="@style/MinuetTheme">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:name="org.qtproject.qt5.android.bindings.QtActivity"
android:label="Minuet"
android:screenOrientation="unspecified"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
......@@ -13,22 +39,36 @@
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so:plugins/bearer/libqandroidbearer.so:lib/libQt5QuickParticles.so"/>
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroidBearer.jar"/>
<meta-data android:name="android.app.static_init_classes" android:value=""/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Used to specify custom system library path to run with local system libs -->
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
<!-- Messages maps -->
<meta-data android:name="android.app.ministro_not_found_msg" android:value="@string/ministro_not_found_msg"/>
<meta-data android:name="android.app.ministro_needed_msg" android:value="@string/ministro_needed_msg"/>
<meta-data android:name="android.app.fatal_error_msg" android:value="@string/fatal_error_msg"/>
<!-- Splash screen -->
<!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you
are done populating your window with content. -->
<!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/splash" / -->
<!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/splash" / -->
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash"/>
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
......@@ -47,24 +87,14 @@
<!-- extract android style -->
<!-- available android:values :
* full - useful for QWidget & Quick Controls 1 apps
* default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
<!-- extract android style -->
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
</application>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- %%INSERT_PERMISSIONS -->
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<!-- %%INSERT_FEATURES -->
</manifest>
#!/bin/bash
cmake ../ -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake -DCMAKE_BUILD_TYPE=Release -DECM_ADDITIONAL_FIND_ROOT_PATH=$Qt5_android -DCMAKE_INSTALL_PREFIX=../import -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DCMAKE_SYSROOT=/data/android-ndk-r10e/platforms/android-17/arch-arm -DCMAKE_ANDROID_API=17
#cmake ../ -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake -DCMAKE_BUILD_TYPE=Release -DECM_ADDITIONAL_FIND_ROOT_PATH=$Qt5_android -DCMAKE_INSTALL_PREFIX=../import -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DCMAKE_SYSROOT=$CMAKE_SYSROOT -DCMAKE_ANDROID_API=29 -DQTANDROID_EXPORTED_TARGET=minuet -DANDROID_APK_DIR=../android/ -DANDROID_ABI=arm64-v8a
# A diretiva -DQTANDROID_EXPORTED_TARGET esta gerando erro na execucao do cmake: nao encontra o cmake do Qt5Core
#cmake -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake -DCMAKE_BUILD_TYPE=Release -DECM_ADDITIONAL_FIND_ROOT_PATH="${Qt5_android}" -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DQTANDROID_EXPORTED_TARGET=minuet -DANDROID_APK_DIR=../android/ -DCMAKE_SYSROOT=/data/android-ndk-r10e/platforms/android-17/arch-arm/ ../
#cmake -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake -DCMAKE_BUILD_TYPE=Release -DECM_ADDITIONAL_FIND_ROOT_PATH="${Qt5_android}" -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DQTANDROID_EXPORTED_TARGET=minuet -DANDROID_APK_DIR=../android/ -DCMAKE_SYSROOT=/data/android-ndk-r10e/platforms/android-29/arch-arm/ ../
cmake ../ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DCMAKE_SYSROOT=$CMAKE_SYSROOT -DCMAKE_ANDROID_API=21 -DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a -DECM_DIR=/usr/share/ECM/cmake/ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH -DCMAKE_PREFIX_PATH=$Qt5_android
make
......@@ -12,4 +14,4 @@ mkdir -p "${INSTALL_DIR}"/lib/qml
make install/strip
make create-apk-minuet
make minuet-apk
#!/bin/bash
cd ../Csound/Android/
export NDK_MODULE_PATH=$PWD/../../Csound-build/android/
export ANDROID_NDK_ROOT=$ANDROID_NDK
./downloadDependencies.sh
sh build-all.sh
{
"description": "This file is generated by qmake to be read by androiddeployqt and should not be modified by hand.",
"qt": "@QT5_INSTALL_PREFIX@",
"sdk": "$ENV{ANDROID_SDK_ROOT}",
"sdkBuildToolsRevision": "@APK_SDK_BUILD_TOOLS_VERSION@",
"ndk": "@CMAKE_ANDROID_NDK@",
"toolchain-prefix": "@APK_NDK_TOOLCHAIN_PREFIX@",
"tool-prefix": "@APK_NDK_TOOLCHAIN_PREFIX@",
"toolchain-version": "@CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION@",
"ndk-host": "@ANDROID_HOST_TAG@",
"target-architecture": "@CMAKE_ANDROID_ARCH_ABI@",
"android-package-source-directory": "@APK_ANDROID_EXTRA_FILES@",
"android-extra-libs": "${APK_EXTRA_LIBS}",
"android-version-name": "1.2.3",
"android-version-code": "0010020031",
"qml-root-path": "@APK_QML_ROOT_PATH@",
"stdcpp-path": "/data/teste-livro/android-ndk-r20/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so",
"useLLVM": true,
"application-binary": "@APK_TARGET_OUTPUT_FILENAME@"
}
include(CMakeParseArguments)
set(QT_ANDROID_MK_APK_DIR ${CMAKE_CURRENT_LIST_DIR})
function(qt_android_build_apk)
set(options)
set(oneValueArgs
TARGET PACKAGE_NAME ANDROID_EXTRA_FILES QML_ROOT_PATH
SDK_BUILD_TOOLS_VERSION EXTRA_LIBS)
set(multiValueArgs)
cmake_parse_arguments(APK "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Gather required variables to create the configuration file.
find_package(Qt5 COMPONENTS Core REQUIRED)
# Qt5Core_DIR now points to $Qt5InstallPrefix/lib/cmake/Qt5Core, so
# we get the parent directory three times:
get_filename_component(QT5_INSTALL_PREFIX "${Qt5Core_DIR}/../../.." ABSOLUTE)
message("Qt5 installed in ${QT5_INSTALL_PREFIX}")
# Adjust QML root path if not set:
if(NOT APK_QML_ROOT_PATH)
set(APK_QML_ROOT_PATH $<TARGET_FILE_DIR:${APK_TARGET}>)
endif()
# Get the toolchain prefix, i.e. the folder name within the
# toolchains/ folder without the compiler version
# APK_NDK_TOOLCHAIN_PREFIX
file(RELATIVE_PATH APK_NDK_TOOLCHAIN_PREFIX ${CMAKE_ANDROID_NDK} ${CMAKE_CXX_COMPILER})
string(REPLACE "/" ";" APK_NDK_TOOLCHAIN_PREFIX ${APK_NDK_TOOLCHAIN_PREFIX})
list(GET APK_NDK_TOOLCHAIN_PREFIX 1 APK_NDK_TOOLCHAIN_PREFIX)
string(REPLACE "clang" "" NEW_CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION ${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION})
if(NOT NEW_CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION STREQUAL "")
string(LENGTH "-${NEW_CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}" VERSION_LENGTH)
string(LENGTH "${APK_NDK_TOOLCHAIN_PREFIX}" FOLDER_LENGTH)
math(EXPR PREFIX_LENGTH ${FOLDER_LENGTH}-${VERSION_LENGTH})
string(SUBSTRING "${APK_NDK_TOOLCHAIN_PREFIX}" 0 ${PREFIX_LENGTH} APK_NDK_TOOLCHAIN_PREFIX)
endif()
# Get path to the target:
set(APK_TARGET_OUTPUT_FILENAME $<TARGET_FILE:${APK_TARGET}>)
# Get Android SDK build tools version:
if(NOT APK_SDK_BUILD_TOOLS_VERSION)
file(GLOB sdk_versions RELATIVE $ENV{ANDROID_SDK_ROOT}/build-tools
$ENV{ANDROID_SDK_ROOT}/build-tools/*)
list(GET sdk_versions -1 APK_SDK_BUILD_TOOLS_VERSION)
endif()
# Step 1: Create an intermediate config file. At this point,
# the generator expressions will we use are not yet resolved.
configure_file(
${QT_ANDROID_MK_APK_DIR}/qt-android-deployment.json.in
${CMAKE_CURRENT_BINARY_DIR}/${APK_TARGET}-config.json.pre)
# Step 2: Run file(CONFIGURE ...) to create the final config JSON
# with generator expressions resolved:
file(
GENERATE
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${APK_TARGET}-config.json
INPUT ${CMAKE_CURRENT_BINARY_DIR}/${APK_TARGET}-config.json.pre)
# Step 3: Create a custom target which will build our APK:
set(APK_DIR ${CMAKE_CURRENT_BINARY_DIR}/${APK_TARGET}-apk-build)
if(NOT APK_ANDROID_EXTRA_FILES)
set(
APK_ANDROID_EXTRA_FILES
${QT5_INSTALL_PREFIX}/src/android/templates/)
endif()
if(JAVA_HOME)
set(ANDROIDDEPLOYQT_EXTRA_ARGS
${ANDROIDDEPLOYQT_EXTRA_ARGS} --jdk '${JAVA_HOME}')
endif()
if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
set(ANDROIDDEPLOYQT_EXTRA_ARGS
${ANDROIDDEPLOYQT_EXTRA_ARGS} --release)
set(APK_FILENAME ${APK_TARGET}-apk-build-release-unsigned.apk)
else()
set(APK_FILENAME ${APK_TARGET}-apk-build-debug.apk)
endif()
add_custom_target(
${APK_TARGET}-apk
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APK_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory
${QT5_INSTALL_PREFIX}/src/android/templates/
${APK_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory
${APK_ANDROID_EXTRA_FILES}/
${APK_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory
${APK_DIR}/libs/${CMAKE_ANDROID_ARCH_ABI}
COMMAND ${CMAKE_COMMAND} -E copy
${APK_TARGET_OUTPUT_FILENAME}
${APK_DIR}/libs/${CMAKE_ANDROID_ARCH_ABI}
COMMAND ${QT5_INSTALL_PREFIX}/bin/androiddeployqt
--verbose
--output ${APK_DIR}
--input ${CMAKE_CURRENT_BINARY_DIR}/${APK_TARGET}-config.json
--deployment bundled
--gradle
${ANDROIDDEPLOYQT_EXTRA_ARGS}
)
# Step 4: Create a custom target which pushes the created APK onto
# the device.
add_custom_target(
${APK_TARGET}-apk-install
COMMAND $ENV{ANDROID_SDK_ROOT}/platform-tools/adb install -r
${APK_DIR}/build/outputs/apk/debug/${APK_FILENAME}
DEPENDS
${APK_TARGET}-apk
)
endfunction()
#!/bin/bash
mkdir android
cd android
git clone https://bitbucket.org/kunstmusik/libsndfile-android.git
cd ..
export BASE_DIR=/data
export ANDROID_NDK=$BASE_DIR/android-ndk-r10e
export ANDROID_SDK_ROOT=$BASE_DIR/sdk-tools-linux-4333796
export Qt5_android=$BASE_DIR/Qt/5.11.2/android_armv7
export PATH=$BASE_DIR/sdk-tools-linux-4333796/platform-tools/:$PATH
export BASE_DIR=/data/teste-livro
export ANDROID_NDK=$BASE_DIR/android-ndk-r20
export ANDROID_SDK_ROOT=$BASE_DIR/android-sdk-4333796
export Qt5_android=$BASE_DIR/Qt/5.13.2/android_arm64_v8a
export PATH=$ANDROID_SDK_ROOT/platform-tools/:$PATH
export ANT=/usr/bin/ant
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk/
export INSTALL_DIR=/home/pdv/install-dir/usr
export CMAKE_SYSROOT=$BASE_DIR/android-ndk-r10e/platforms/android-17/arch-arm/
export INSTALL_DIR=../install
export CMAKE_SYSROOT=$ANDROID_NDK/platforms/android-21/arch-arm64
......@@ -40,7 +40,19 @@ IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
ecm_install_icons(ICONS ${minuet_ICONS_PNG} ${minuet_ICONS_SVG} DESTINATION ${ICON_INSTALL_DIR} THEME hicolor)
ENDIF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
add_executable(minuet ${minuet_SRCS})
if(ANDROID)
include(../../cmake/qt-android-mk-apk.cmake)
add_library(minuet SHARED ${minuet_SRCS})
qt_android_build_apk(
TARGET ${PROJECT_NAME}
PACKAGE_NAME org.kde.minuet
QML_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}
ANDROID_EXTRA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../android
EXTRA_LIBS ../plugins/csoundsoundcontroller/libminuetcsoundsoundcontroller.so,../interfaces/libminuetinterfaces.so,../../src/plugins/csoundsoundcontroller/Csound-prefix/src/Csound/Android/CsoundAndroid/libs/arm64-v8a/libcsoundandroid.so,../../src/plugins/csoundsoundcontroller/Csound-prefix/src/Csound/Android/CsoundAndroid/libs/arm64-v8a/libsndfile.so,../../src/plugins/csoundsoundcontroller/Csound-prefix/src/Csound/Android/pluginlibs/libfluidsynth/libs/arm64-v8a/libfluidOpcodes.so,../../src/plugins/csoundsoundcontroller/Csound-prefix/src/Csound/Android/CsoundAndroid/libs/arm64-v8a/libc++_shared.so
)
else()
add_executable(minuet ${minuet_SRCS})
endif()
target_link_libraries(minuet
Qt5::Core
......@@ -52,11 +64,11 @@ target_link_libraries(minuet
Minuet::Interfaces
)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Android")
if(ANDROID)
target_link_libraries(minuet
Minuet::CsoundSoundController
)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Android")
endif()
IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
target_link_libraries(minuet
......
......@@ -117,17 +117,18 @@ QJsonArray ExerciseController::exercises() const
bool ExerciseController::mergeJsonFiles(const QString directoryName, QJsonObject &targetObject, bool applyDefinitionsFlag, QString commonKey, QString mergeKey)
{
#if defined(Q_OS_ANDROID)
QStringList jsonDirs;
jsonDirs += "/data/data/org.kde.minuet/qt-reserved-files/share/minuet/" + directoryName;
#if defined(Q_OS_ANDROID)
jsonDirs << "assets:/data/" + directoryName;
#elif defined(Q_OS_WIN)
QStringList jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, QStringLiteral("minuet/") + directoryName, QStandardPaths::LocateDirectory);
jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, QStringLiteral("minuet/") + directoryName, QStandardPaths::LocateDirectory);
#else
QStringList jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, directoryName, QStandardPaths::LocateDirectory);
jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, directoryName, QStandardPaths::LocateDirectory);
#endif
foreach (const QString &jsonDirString, jsonDirs) {
QDir jsonDir(jsonDirString);
foreach (const QString &json, jsonDir.entryList(QDir::Files)) {
if (!json.endsWith(".json")) break;
QFile jsonFile(jsonDir.absoluteFilePath(json));
if (!jsonFile.open(QIODevice::ReadOnly)) {
#if !defined(Q_OS_ANDROID)
......
......@@ -30,8 +30,12 @@
#endif
#include <QIcon>
#include <QFile>
#include <QGuiApplication>
#include <QCommandLineParser>
#include <QDir>
#include <QDebug>
int main(int argc, char *argv[])
{
......@@ -68,6 +72,12 @@ int main(int argc, char *argv[])
KAboutData::setApplicationData(aboutData);
#endif
#if defined(Q_OS_ANDROID)
if (!QFile("/data/data/org.kde.minuet/files/sf_GMbank.sf2").exists()) {
if(QFile("assets:/share/sf_GMbank.sf2").copy("/data/data/org.kde.minuet/files/sf_GMbank.sf2"))
qDebug() << "COPIED " << QFileInfo("/data/data/org.kde.minuet/files/sf_GMbank.sf2").size() << "b soundfound file to /data/data/org.kde.minuet/files/sf_GMbank.sf2";
}
#endif
Minuet::Core::initialize();
return application.exec();
......
include(ExternalProject)
ExternalProject_Add(CsoundForAndroid
URL https://github.com/csound/csound/releases/download/6.11.0/Csound6.11.0-Android.zip
URL_HASH MD5=f2aeb39b5f227ae19c92f31b23d56342
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
ExternalProject_Add(Csound
GIT_REPOSITORY https://github.com/csound/csound.git
GIT_TAG 6.11.0
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
CONFIGURE_COMMAND "${CMAKE_SOURCE_DIR}/configure-csound-android.sh"
BUILD_COMMAND "${CMAKE_SOURCE_DIR}/build-csound-android.sh"
INSTALL_COMMAND ""
)
set(CSOUND_ANDROID_LIBS_DIR ${CMAKE_CURRENT_BINARY_DIR}/CsoundForAndroid-prefix/src/CsoundForAndroid/CsoundForAndroid/CsoundAndroid/src/main/jniLibs/armeabi-v7a)
set(CSOUND_ANDROID_LIBS_DIR ${CMAKE_CURRENT_BINARY_DIR}/Csound-prefix/src/Csound/Android/CsoundAndroid/libs/arm64-v8a/)
set(CSOUND_ROOT ${CMAKE_CURRENT_BINARY_DIR}/Csound-prefix/src/Csound/)
set(CSOUND_ANDROID ${CSOUND_ANDROID_LIBS_DIR}/libcsoundandroid.so)
......@@ -25,8 +17,8 @@ set(CSOUND_SND ${CSOUND_ANDROID_LIBS_DIR}/libsndfile.so)
set(CSOUND_LIBS ${CSOUND_ANDROID} ${CSOUND_SHARED} ${CSOUND_SND})
include_directories(${CSOUND_ROOT}/include)
include_directories(${CSOUND_ROOT}/Android/CsoundAndroid/jni/)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Csound-prefix/src/Csound/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Csound-prefix/src/Csound/Android/CsoundAndroid/jni)
set(csoundsoundcontroller_PLUGIN_SRCS
csengine.cpp
......@@ -42,7 +34,7 @@ target_link_libraries(minuetcsoundsoundcontroller
${CSOUND_LIBS}
)
add_dependencies(minuetcsoundsoundcontroller CsoundForAndroid Csound)
add_dependencies(minuetcsoundsoundcontroller Csound)
IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
install(TARGETS minuetcsoundsoundcontroller DESTINATION ${PLUGIN_INSTALL_DIR}/minuet/)
......
......@@ -26,6 +26,7 @@
#include <QStringList>
#include <QDir>
#include <QStandardPaths>
#include <QCoreApplication>
CsEngine::CsEngine()
{
......@@ -35,15 +36,26 @@ CsEngine::CsEngine()
void CsEngine::run()
{
cs.setOpenSlCallbacks(); // for android audio to work
cs.Compile(m_fileName);
cs.Start();
cs.Perform();
cs.Cleanup();
cs.Reset();
cs.Stop();
QFile file(m_fileName);
file.open(QIODevice::ReadOnly);
qDebug() << "Template: ";
while (!file.atEnd())
qDebug() << file.readLine();
file.close();
qWarning() << "Dir " << QDir::currentPath() << " contains sf_GMbank.sf2? " << QDir::current().entryList(QDir::Files).contains("sf_GMbank.sf2");
qWarning() << "Dir " << QCoreApplication::applicationDirPath() << " contains libfluidOpcodes.so? " << QDir(QCoreApplication::applicationDirPath()).entryList(QDir::Files).contains("libfluidOpcodes.so");
qDebug() << "READING " << QDir::currentPath() + "/template.csd";
qDebug() << "SOUNDFONT EXISTS? " << QFile("/data/data/org.kde.minuet/files/sf_GMbank.sf2").exists() << " " << QFileInfo("/data/data/org.kde.minuet/files/sf_GMbank.sf2").size() << "b";
if (cs.Compile(m_fileName)) {
cs.Start();
cs.Perform();
cs.Cleanup();
cs.Reset();
cs.Stop();
}
}
void CsEngine::stop()
{
cs.Stop();
// cs.Stop();
}
......@@ -42,8 +42,28 @@ void CsoundSoundController::openExerciseFile()
{
QStringList templateList;
templateList.append(QStringLiteral("assets:/share/template.csd"));
templateList.append(QStringLiteral("assets:/share/template_rhythm.csd"));
// templateList.append(QStringLiteral("assets:/share/template_rhythm.csd"));
qDebug() << "DIRPATH: " << QCoreApplication::applicationDirPath();
qDebug() << "ASSETSPATH: " << QDir("assets:/").canonicalPath();
qDebug() << "QStandardPaths::ApplicationsLocation: " << QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
qDebug() << "QStandardPaths::GenericDataLocation: " << QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
qDebug() << "QStandardPaths::AppDataLocation: " << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
qDebug() << "QStandardPaths::AppLocalDataLocation: " << QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation);
qDebug() << "QStandardPaths::AppConfigLocation: " << QStandardPaths::standardLocations(QStandardPaths::AppConfigLocation);
QDir appDir(QCoreApplication::applicationDirPath());
qDebug() << "Contains libfluidOpcodes.so? " << appDir.entryList(QDir::Files).contains("libfluidOpcodes.so");
qDebug() << "DIRPATH: " << appDir << " Contents: " << appDir.entryList(QDir::AllEntries);
appDir.cdUp();
qDebug() << "DIRPATH: " << appDir << " Contents: " << appDir.entryList(QDir::AllEntries);
appDir.cdUp();
qDebug() << "DIRPATH: " << appDir << " Contents: " << appDir.entryList(QDir::AllEntries);
QDir reserved("/data/data/org.kde.minuet/qt-reserved-files/");
qDebug() << "RESERVED: " << reserved << " Contents: " << reserved.entryList(QDir::AllEntries);
QDirIterator it("/", QDirIterator::Subdirectories);
while (it.hasNext())
qDebug() << "FILE: " << it.next();
foreach (const QString &templateString, templateList) {
QFile sfile(templateString);
if (!sfile.open(QIODevice::ReadOnly | QIODevice::Text))
......@@ -56,6 +76,7 @@ void CsoundSoundController::openExerciseFile()
while (!in.atEnd()) {
lineData = in.readLine();
lineData.replace("APPDIRPATH", QCoreApplication::applicationDirPath());
tempBeginLine = tempBeginLine + lineData + "\n";
if (lineData.contains("<CsScore>")) {
m_begLine.append(tempBeginLine);
......@@ -69,6 +90,8 @@ void CsoundSoundController::openExerciseFile()
}
m_endLine.append(tempEndLine);
}
qDebug() << "m_begLine: " << m_begLine;
qDebug() << "m_endLine: " << m_endLine;
}
void CsoundSoundController::appendEvent(QList<unsigned int> midiNotes, QList<float> barStartInfo, QString playMode)
......@@ -79,6 +102,7 @@ void CsoundSoundController::appendEvent(QList<unsigned int> midiNotes, QList<flo
QString fifthParam = QStringLiteral("100");
QFile m_csdFileOpen(QStringLiteral("./template.csd"));
qDebug() << "CREATING " << QDir::currentPath() + "/template.csd";
if(!m_csdFileOpen.isOpen()) {
m_csdFileOpen.open(QIODevice::ReadWrite | QIODevice::Text);
}
......@@ -92,12 +116,12 @@ void CsoundSoundController::appendEvent(QList<unsigned int> midiNotes, QList<flo
for(int i=0; i<midiNotes.count(); i++) {
QString initScore = QString("i 1 %1 %2 %3 %4\n").arg(QString::number(barStartInfo.at(i))).arg(QString::number(1)).arg(QString::number(midiNotes.at(i))).arg(fifthParam);
content += initScore;
// content += initScore;
}
if (playMode != "rhythm") {
QString instrInit = "i 99 0 " + QString::number(barStartInfo.at(barStartInfo.count()-1)+1) + "\ne\n";//instrument will be active till the end of the notes +1 second
content += instrInit;
// content += instrInit;
}
QString templateContent = m_begLine[templateNumber] + content + m_endLine[templateNumber];
......
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
--opcode-lib=/data/data/org.kde.minuet/qt-reserved-files/share/libfluidOpcodes.so
-odac ;;;realtime audio out and realtime midi in
;-iadc ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
;-o fluidNote.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
giengine fluidEngine
; soundfont path to manual/examples
isfnum fluidLoad "/data/data/org.kde.minuet/qt-reserved-files/share/sf_GMbank.sf2", giengine, 1
fluidProgramSelect giengine, 1, isfnum, 0, 0
instr 1
mididefault 60, p3
midinoteonkey p4, p5
ikey init p4
ivel init p5
fluidNote giengine, 1, ikey, ivel
endin
instr 99
imvol init 7
asigl, asigr fluidOut giengine
outs asigl*imvol, asigr*imvol
endin
</CsInstruments>
<CsScore>
</CsScore>
</CsoundSynthesizer>
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
;;;RT audio out, midi in, note=p4 and velocity=p5
--opcode-lib=/data/data/org.kde.minuet/qt-reserved-files/share/libfluidOpcodes.so
-odac
;-+rtmidi=virtual -M0d --midi-key=4 --midi-velocity-amp=5
;-iadc ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o cpsmidinn.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
massign 0, 1 ;assign all midi to instr. 1