Giter Club home page Giter Club logo

pd-for-android's Introduction

libpd

Pure Data as an embeddable audio synthesis library

Copyright (c) Peter Brinkmann & the libpd team 2010-2023

Documentation

For documentation of libpd, see the wiki: https://github.com/libpd/libpd/wiki

If you are using Processing, iOS, or Android, see our companion repositories:

Getting libpd

The preferred method to download libpd is to use git.

Do not download libpd as a zip or tar.gz file from GitHub.

The "Download ZIP" button may look like a good idea, but currently Github does not include submodule files when compiling zip files. This means the zip file is missing the main pd source files and you will not be able to build libpd, with errors such as: No rule to make target pure-data/src/d_arithmetic.o or No such file or directory: pure-data/extra/bonk~/bonk~.c.

To download libpd & check out the pure-data submodule, do the following:

git clone --recurse-submodules https://github.com/libpd/libpd.git

You should now have a libpd directory and the libpd/pure-data directory should contain the pd sources.

Note: If your version of git does not support "--recurse-submodules", you can run the git submodule commands in the libpd directory itself after cloning:

cd libpd
git submodule update --init --recursive

For most uses, it is recommended to check out the latest stable release version via a git tag. For example, to switch to libpd version 0.8.3 after cloning:

git checkout 0.8.3
git submodule update

The master branch contains the latest libpd development and can be considered generally stable. However, we make no guarantees. :)

Repository Layout

pure-data

The directory containing the sources of Pd Vanilla and it's standard externals. This is a git submodule of Miller Puckette's official Pd git repository:

git://git.code.sf.net/p/pure-data/pure-data

libpd_wrapper

This directory contains the source files that make up the core of libpd.

Android.mk, Makefile, libpd.xcodeproj, libpd_csharp.sln, .classpath, .project

Build support for various platforms. Feel free to improve the build system in any way you see fit.

cpp, csharp, java, jni, objc, python

Glue for using libpd with C++, C#, Java, Objective-C, and Python. Feel free to improve or add support for other languages such as Lua.

samples

Small sample programs and tests in the various supported languages.

libs

The build result location and required software libraries for the various supported languages.

Building libpd

Core build requirments:

  • Unix command shell: bash, dash, etc
  • C compiler chain: gcc/clang & make

Note: The various language wrappers may have additional requirements.

Currently the main Makefile builds a dynamic lib on Windows (in MinGW), Linux, & macOS and has the following targets:

  • libpd: build the libpd C core, default if no target is specified
  • csharplib: build libpdcsharp
  • javalib: build libpdnative and the jni wrapper
  • javadoc: generate Java HTML documentation
  • javasrc: create a Java source jar
  • clean: remove object files
  • clobber: remove linked library files
  • install: install libpd C library and C/C++* headers, set location with prefix= (default: /usr/local)
  • uninstall: remove libpd C library and C/C++ headers, set location with prefix= (default: /usr/local)

* C++ headers are only installed if the C utility layers were built as well (ie. UTIL=true), see below.

Makefile options allow for conditional compilation of libpd util and pd extra externals sources into libpd as well as other options:

  • UTIL=true: compile utilities in libpd_wrapper/util (default)
  • EXTRA=true: compile pure-data/extra externals which are then inited in libpd_init() (default)
  • MULTI=true: compile with multiple instance support
  • DOUBLE=true: compile with double-precision support
  • DEBUG=true: compile with debug symbols & no optimizations
  • STATIC=true: compile static library (in addition to shared library)
  • FAT_LIB=true: compile universal "fat" lib with multiple architectures (macOS only)
  • LOCALE=false: do not set the LC_NUMERIC number format to the default "C" locale* (default)
  • PORTAUDIO=true: compile with portaudio support (currently JAVA jni only)
  • JAVA_HOME=/path/to/jdk: specify the path to the Java Development Kit

To build the libpd C core with default options:

make

To build libpd without the util libs and extra externals:

make UTIL=false EXTRA=false

Note: The C++ wrapper requires UTIL=true as it uses the ringbuffer.

* See the Known Issues section for more info.

If you need to add custom search paths to the CFLAGS or LDFLAGS, you can specify them when building via the ADDITIONAL_* variables:

make ADDITIONAL_CFLAGS="-I/usr/local/include" \
     ADDITIONAL_LDFLAGS="-L/usr/local/lib"

Once libpd has built successfully, the compiled libraries will be found in the libs directory.

Linux & BSD

Install the core build requirements using your distribution's package manager. For Debian, you can install the compiler chain, autotools, & gettext with:

sudo apt-get install build-essentials

macOS

macOS is built on top of a BSD system and the bash or zsh commandline can be accessed with the Terminal application in the /Applications/Utility directory.

Xcode

The clang compiler and associated tools are provided by Apple. If you are running macOS 10.9+, you do not need to install the full Xcode application and can install the Commandline Tools Package only by running the following:

xcode-select --install

If you are running macOS 10.6 - 10.8, you will need to install Xcode from the Mac App Store or downloaded from http://developer.apple.com

Fat Libs

By building with the FAT_LIB=true Makefile option, libpd will be compiled with support for multiple architectures depending on the detected system version:

  • macOS <= 10.13: i386 (32 bit Intel) & x86_64 (64 bit Intel)
  • macOS >= 11.0: arm64 (64 bit Arm) & x86_64 (64 bit Intel)

To override autodetection, specify the -arch flags directly using the FAT_ARCHS Makefile option:

make FAT_LIB=true FAT_ARCHS="-arch i386 -arch x86_64"

Windows

libpd on Windows can be built with MinGW which provides the core build requirements: a compiler chain & shell environment. It is recommended to use the Msys2 distribution which provides both a Unix command shell and MinGW. Download the Msys2 "x86_64" 64 bit installer (or "i686" if you are using 32 bit Windows) from:

http://www.msys2.org/

Then install to the default location (C:\msys32 or C:\msys64) and follow the setup/update info on the Msys2 webpage.

Msys2 provides both 32 and 64 bit MinGW and command shells which are used to compile for 32 or 64 bit, respectively. Due to how MinGW is designed, you cannot build a 64 bit libpd with a 32 bit MinGW and vice versa.

Note: Msys2 development seems to change frequently, so some of the package names below may have changed after this document was written.

Open an Msys2 shell and install the compiler chain & make via:

# 32 bit
pacman -S mingw-w64-i686-toolchain mingw-w64-i686-clang make

# 64 bit
pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang make

You can also search for packages in Msys2 with pacman -S -s <searchterm>.

Once the packages are installed, you should now be ready to build libpd.

Note: For 64 bit Windows, build Pd with the following additional C flags to ensure long integers are the correct length:

make ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long"'

If you run into strange errors such as /bin/sh: cc: command not found, try closing and reopening your shell window before building again.

Double-Precision Support

By default, libpd computes numbers and samples internally as single-precision 32-bit floats. This is fast and good enough for most general usage. If you are working with small numbers beyond 6 decimal points, however, you will need a higher degree of precision.

To enable double-precision 64-bit floating point support, build libpd with -DPD_FLOATSIZE=64 in the CFLAGS. The libpd makefile provides the DOUBLE makefile variable for this:

make DOUBLE=true

Now utilize the libpd API which use the double type, such as the libpd double hook, libpd_add_double(), and libpd_process_double().

To double-check your build, the following will print a 1 if double-precision support is enabled:

printf("double-precision %d\n", (int)(sizeof(t_float)/8));

Loading Externals

Libpd can load pre-compiled dynamic libraries of external objects in the same manner as desktop Pd if it is compiled with the -ldl LDFLAG. This is done by default in the Makefile. The main difference is that libpd does not inherit the same search paths by default, so paths outside of those specified by the loading patch with [declare] objects need to be added via libpd's "add to search path" function.

Multi-Instance Compatibility

If libpd is compiled with multi-instance support via make MULIT=true and -DPDINSTANCE -DPDTHREADS are defined, it may have trouble loading dynamic externals which are compiled without them:

vbap.pd_linux: vbap.pd_linux: undefined symbol: pd_this
 vbap
... couldn't create

In this case, the vbap external needs to be recompiled with the -DPDINSTANCE -DPDTHREADS CFLAGS defined to add multi-instance support to match.

C++

The C++ wrapper is inspired by the Java wrapper and provides a PdBase class as well as listener, list, and message type classes. This is a header only library so you only need to include the cpp directory in your project. You also may need to add libpd_wrapper/util to you include paths.

Sample programs are found in samples/cpp.

Multiple Instance Support

By default, PdBase always wraps to the single main libpd instance, so it is recommended to only use one instance of PdBase.

If PDINSTANCE is defined, each PdBase will wrap a separate libpd instance.

To enable multiple instance support:

  • Build libpd with make MULTI=true or with CFLAGS -DPDINSTANCE -DPDTHREADS
  • Build the C++ program using PdBase.hpp with CPPFLAGS -DPDINSTANCE

C#

Installation from NuGet

The libpd C# library is available as a NuGet package:

https://www.nuget.org/packages/LibPdBinding

If your platform's native libpdcsharp.(so/dll) is not included, you have to build it yourself following and copy the resulting file to the output directory. Batch scripts for compilation on Windows with MinGW are included.

Building yourself

The C# library expects a file libpdcsharp.(so/dll) in its directory. Before using the project, you need to compile it:

make csharplib

Include csharp/LibPdBinding.csproj in your solution and reference the project in your application. See csharp/README.txt for details.

Windows

The wrapper can be built with MinGW. See the previous "Windows" section for instructions on setting up a MinGW-based build environment using Msys2.

Build libpdcsharp using the the .bat DOS batch file wrappers for make to match which MinGW you are using:

# 32 bit
./mingw32_build_csharp.bat

# 64 bit
./mingw64_build_csharp.bat

Usually you want the 32 bit version, as it will work on 64 bit Windows as well. However so C# environments require a 64 bit version, Unity 5 for instance.

Once the build is finished, a libpdcsharp.(so/dll) library should be found in the libs directory

You also may need to use the libwinpthread library along with libpdcsharp. This included with libpd in the libs directory, either within libs/mingw32 or libs/mingw64. For a current version of libwinpthread-1.dll search in your Msys2 installation's bin directory.

Note: If you have installed Msys2 to a non-default location, you will need to change the variable for %MSYS2% in the .bat files.

Linux

If you want to use the library on Linux with Mono, you need the following changes to the LibPdBinding project:

  1. Compile the .so file with make csharplib.
  2. Remove libpdcsharp.dll and libwinpthread-1.dll from LibPdBinding project.
  3. Add libpdcsharp.so to the LibPdBinding project.
  4. Set "Copy to Output Directory" for libpdcsharp.so to "Copy always"

Java

Precompiled Binaries

May be out of date

Ready-made binaries for Java are available at the libpd-java-build repository:

https://github.com/wivlaro/libpd-java-build

Building Yourself

You will need the Java Development Kit (JDK) to build the libpd Java lib. Make sure the JDK/bin path is added to your $PATH shell variable and, optionally, the JAVA_HOME variable points to the JDK location.

Build the libpd Java lib with:

make javalib

This should result in a libpd.jar and pdnative.(so/dll) in the libs directory.

Optionally, you can build libpd with Eclipse using the .classpath & .project workspace files.

You can also build a libpd source jar and Java HTML documentation:

make javasrc
make javadoc

This should result in a libs/libpd-sources.jar and a javadoc directory.

Linux & BSD

Install the JDK via your distributions package manager.

macOS

Install the JDK either by downloading an installer package or by using one of the open source package managers for macOS:

Windows

The wrapper can be built with MinGW. See the previous "Windows" section for instructions on setting up a MinGW-based build environment using Msys2.

Install the JDK by downloading an installer package, then add the path to JDK/bin to your $PATH shell variable and the JDK path to $JAVA_HOME (optional). If the JDK is installed to C:\Program Files\Java\jdk1.8.0_152, add the following to your ~/.bash_profile:

# add JDK bin path
export PATH=$PATH:'C:\Program Files\Java\jdk1.8.0_152\bin'

# JDK path (optional)
export JAVA_HOME=C:/Program\ Files/Java/jdk1.8.0_152

Restart your shell if it's open.

Build the libpd javalib with:

make javalib

You can also set the JAVA_HOME path when running make with:

make javalib JAVA_HOME=C:/Program\ Files/Java/jdk1.8.0_152

Once the build is finished, you should find libpd.jar and pdnative.(so/dll) in the libs directory.

Objective-C

The Objective-C wrapper is designed to be used on iOS and macOS and includes a (currently iOS-only) audio unit and audio manager for sound I/O.

Xcode Project

libpd.xcodeproj provides an Xcode project to build libpd + the Obj-C wrapper as a static library for iOS & macOS. Drag the libpd project into your existing Xcode project, then add libpd-ios (or libpd-osx) to the Linked Frameworks and Libraries in the General tab of your project target.

The Xcode project builds the following targets:

  • libpd-ios: libpd and the Obj-C wrapper for iOS
  • libpd-osx: libpd and the Obj-C wrapper for macOS
  • libpd-ios-multi: libpd for iOS with multiple instance support
  • libpd-osx-multi: libpd for macOS with multiple instance support

For detailed instructions, see Working with libpd in Xcode

If you are unfamiliar with how static libraries work or how to use them in Xcode, see this useful tutorial.

Note: libpd is tested with the release versions of Xcode. It is recommended that you avoid using beta or developer preview versions.

CocoaPods

If you are using Xcode to build iOS apps, you can use CocoaPods to add libpd to your project.

Use the following in your CocoaPods podfile:

pod 'libpd', :git => 'https://github.com/libpd/libpd', :submodules => true

To specify a stable version tag, use the :tag option:

pod 'libpd', :git => 'https://github.com/libpd/libpd', :submodules => true, :tag => '0.12.1'

Python

The Python wrapper provides a "pylibpd" module mirroring the libpd C API. Build the wrapper with:

cd python
make

See the sample programs in samples/python.

If you have multiple versions of Python on your system, you can specify which is used to build the module via the PYTHON makefile option:

make PYTHON=python3

If you are building for 64-bit Windows, you may need to set the additional MS_WIN64 flag:

make CFLAGS="-DMS_WIN64=1"

pyaudio

Some samples require the "pyaudio" Portaudio library.

If you install pyaudio with pip, you will need to install Portaudio first. On macOS, for example, you can install it with Homebrew:

brew install portaudio

Rust

There is currently a third party Rust wrapper for libpd called libpd-rs which is actively maintained.

libpd-rs uses a fork of libpd which is frequently synchronized with upstream.

Please visit the repository for detailed information.

Building with CMake

CMake can be used to build the libpd C library.

CMake is a cross-platform, open-source build system. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice.

Dependencies

  • CMake: You can download CMake for your platform here. The minimum version is 2.8.11.
  • pthreads: On Windows, you need to provide a pthreads library.

If you are using MinGW, you can use the libwinpthread-1.dll included in the libs/mingw* directories in this repository. Alternatively, you can also download it or compile it yourself from the sources here. This will typically result in pthreadGC2.(dll/lib).

If you are using Visual Studio, you need to provide a pthreads library compiled for Visual Studio either by downloading it or compiling it yourself. See here. Be careful to download / compile the right version for your setup. This would typically be pthreadVC2.(dll/lib).

Configuring the build

One way to configure CMake is to use the CMake GUI. The GUI will list the variables that can be provided to configure the build. The variables can also be specified in the command-line interface (See below for an example)

In this step you can select the features to be included with PD_EXTRA, PD_LOCALE, PD_MULTI and PD_UTILS as described above. You can also enable building the C sample programs using PD_BUILD_C_EXAMPLES.

When using Microsoft Visual Studio (MSVC), you will be requested to provide a path to the pthreads library and its headers using variables CMAKE_THREAD_LIBS_INIT and PTHREADS_INCLUDE_DIR.

On macOS, you can define different deployment target and architectures from your current system using the variables CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_ARCHITECTURES.

You can specify additional compilation flags using the variable CMAKE_C_FLAGS.

CMake can now generate Makefiles, a MSVC solution, or an XCode project.

Building

After generation, depending on your platform you can navigate to the directory where CMake generated the build files and then:

  • On Linux: run make
  • On Windows: open the MSVC solution and build it
  • On macOS: open the XCode project and build it

Of course you can also use CMake itself to build libpd by running this on the command line:

cd <path/to/build/files/generated/by/CMake>
cmake --build .

Windows cross-compilation on Linux

You can build Windows binaries in Linux using MinGW. This will only build the static and shared libraries, and not the C# bindings.

The easiest way is to set up a toolchain file for CMake pointing to all the necessary MinGW tools. For debian-based distributions, the file would contain the following:

SET(CMAKE_SYSTEM_NAME Windows)

SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)

SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Note paths and binary names might vary in other distributions.

You can then use the CMAKE_TOOLCHAIN_FILE option to tell CMake to load the settings from your file. For example, if the above is saved to $HOME/.local/share/cmake/toolchain-mingw-x86_64-w64.cmake, then CMake can be invoked with

cmake -DCMAKE_TOOLCHAIN_FILE=$HOME/.local/share/cmake/toolchain-mingw-x86_64-w64.cmake

followed by any other CMake options you'd normally use, and the source directory.

Command-line examples

Here are examples of how to download, configure and build the latest libpd on the command line using CMake.

Linux:

git clone https://github.com/libpd/libpd
cd libpd
git submodule init
git submodule update
mkdir build && cd build
cmake .. -DPD_MULTI:BOOL=ON -DPD_BUILD_C_EXAMPLES:BOOL=ON
cmake --build .

Windows / MSVC:

git clone https://github.com/libpd/libpd
cd libpd
git submodule init
git submodule update
mkdir build && cd build
cmake .. -DCMAKE_THREAD_LIBS_INIT:PATH=</path/to/pthreadsVC2.lib> -DPTHREADS_INCLUDE_DIR:PATH=</path/to/pthread/header/files>
cmake --build .

Limitations

Currently the CMake script is not capable of building the C# or the Java bindings. Please use the makefile for that.

Known Issues

How do I use libpd in Visual Studio?

Historically, Pd was designed to be built using the open source gcc & make and did not directly support being built in Visual Studio on Windows, mainly due to differences in C compiler versions.

Recently, the code has been adapted and a CMake build script has been developed that should allow you to generate a MSVC solution. The only important thing you need to be careful about is providing a pthreads library compiled for Visual Studio. See the section above about building with CMake.

Another possible approach is building the libpd C library using gcc and make using MinGW in msys on Windows. You can use the resulting .dll, .def, & .lib files with Visual Studio and the cpp wrapper is provided as an all header library so it should work directly within VS as well.

After building libpd in msys, you can "install" it to a temp directory to get only the libs and headers you need:

make install prefix=libpd-build

Problems with numbers in loaded patches or DSP output always seems to be 0

Pd expects numbers to be in an English format, ie. "0.3". If you are using a non-English language or locale setting on your system, it may be encoding numbers differently, ie. "0,3". This can lead to weird bugs in loaded patches where numbers seem wrong or end up truncated as 0.

By default, libpd is built with the LC_NUMERIC locale set to the "C" default, so this shouldn't be a problem. If you are using libpd within a project that requires specific locale settings, you will need to make sure libpd's LC_NUMERIC is left alone or at least reset it to "C" if working with a different numeric setting. If a non-English LC_NUMERIC is set, you will run into the number parsing issues mentioned above.

If you need to control LC_NUMERIC manually, you can build libpd without the call to setlocale() in libpd_init using the SETLOCALE=false makefile option or by setting the LIBPD_NO_NUMERIC define.

See #130 for more info.

pd-for-android's People

Contributors

chr15m avatar eighthave avatar jamesnitsch avatar joebowbeer avatar nettoyeurny avatar residuum avatar tkirshboim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pd-for-android's Issues

Android Audio Best Practices (Google I/O 17)

Recently at Google I/O 17, Android Audio team put forth some recommendations to improve audio performance: https://youtu.be/C0BPXZIvG-Q?t=10m13s

I am wondering if pd-for-android can take advantage of these recommendations and how. I have summarized the best practices here.

Obtain low latency audio paths

Check for audio.pro hardware flag, which means that the device is capable of less than 20ms latency

Recording

  • use VOICE_RECOGNITION preset to by pass system effects
  • use PCM16 format which avoids any format shifting

Playback

Meet audio deadlines

Additional recommendations for the callback implementation to avoid glitches

  • avoid logging. use systrace instead.
  • avoid memory allocation
  • don't wait on other threads
  • don't do file i/o. Instead, use another thread to do read file and transfer the data using circular buffer or non-blocking queue
  • don't sleep
  • prevent cpu core migration by setting thread affinity, or using getExclusiveCores()
  • prevent cpu frequency scaling by adding a stabilizing load
  • use Sustained Performance Mode

How to use samples with Android Studio?

Just briefly tried running PdTest in Android Studio (1.2.2) by importing the project from ADT and got the following error message:

Error:The project is using an unsupported version of Gradle.

Does anyone know if it is possible to use Android Studio and how, or must I still use Eclpse ADT?

Thanks!

errors when set the compileSdkVersion to 23 in PdCore and AndroiMidi modules

Hi I have errors when set the compileSdkVersion to 23 in PdCore and AndroiMidi modules.

First error is:
Error:(20, 23) error: package org.apache.http does not exist
...

I found this solution:
add this line to build.gradle (AndroidMidi) : useLibrary 'org.apache.http.legacy'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
...
}

Second error :
Error:(252, 16) error: cannot find symbol method setLatestEventInfo(PdService,String,String,PendingIntent)

    @SuppressWarnings("deprecation")
    protected Notification makeNotification(Intent intent, int icon, String title, String description)   {
        PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
        Notification notification = new Notification(icon, title, System.currentTimeMillis());
        notification.setLatestEventInfo(PdService.this, title, description, pi);
        notification.flags |= Notification.FLAG_ONGOING_EVENT;
        return notification;
    }

I try to fix it with the new Notification.Builder (http://developer.android.com/reference/android/app/Notification.Builder.html)
but without success.

Can I use these modules to the SDK API 23?
Is there any problem if I continue using the API 22 for the modules and the API 23 for the app?
Thank you for your attention

armeabi deprecated

Under PdCore -> jni -> Application.mk,
APP_ABI := armeabi armeabi-v7a x86 needs to be changed to APP_ABI := armeabi-v7a x86
as armeabi is deprecated and the ndk build of PdCore will fail with exit status 2.

My externals won't run on amd64-v8

Some of my own externals are failing to run on devices with amd64-v8. They seem to compile fine and gets copied over to the apk in the right folder (armeabi-v7a, arm64-v8a etc). When I run my app on an older device everything runs fine.

The error message is "error: ... couldn't create" when the patch is run. I am on pd-core version 1.1.0.

Thanks for any suggestions.

My Application.mk:

APP_PLATFORM := android-17
APP_OPTIM := release
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
APP_ALLOW_MISSING_DEPS=true

In Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := pd
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../pd-for-android/PdCore/jni/libpd/pure-data/src
LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../pd-for-android/PdCore/libs/$(TARGET_ARCH_ABI)/libpd.so
ifneq ($(MAKECMDGOALS),clean)
    include $(PREBUILT_SHARED_LIBRARY)
endif

#---------------------------------------------------------------

include $(CLEAR_VARS)
LOCAL_MODULE := samplelooper_tilde
LOCAL_CFLAGS := -DPD -std=c99
LOCAL_SRC_FILES := samplelooper~.c
LOCAL_SHARED_LIBRARIES = pd
include $(BUILD_SHARED_LIBRARY)

...etc same for all

Output from buildNatives:

14:38:22: Executing task 'buildNative'...

Executing tasks: [buildNative]

Configuration on demand is an incubating feature.

> Configure project :
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Task :android:buildNative
Android NDK: WARNING: APP_PLATFORM android-17 is higher than android:minSdkVersion 1 in /---/android/AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android-17. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.    
make: Entering directory `/---/android/jni'
[armeabi-v7a] Compile thumb  : samplelooper_tilde <= samplelooper~.c
[arm64-v8a] Compile        : samplelooper_tilde <= samplelooper~.c
[x86] Compile        : samplelooper_tilde <= samplelooper~.c
[x86_64] Compile        : samplelooper_tilde <= samplelooper~.c
[armeabi-v7a] Install        : libpd.so => libs/armeabi-v7a/libpd.so
[arm64-v8a] Install        : libpd.so => libs/arm64-v8a/libpd.so
[x86] Install        : libpd.so => libs/x86/libpd.so
[x86_64] Install        : libpd.so => libs/x86_64/libpd.so
[armeabi-v7a] SharedLibrary  : libsamplelooper_tilde.so
[x86] SharedLibrary  : libsamplelooper_tilde.so
[armeabi-v7a] Install        : libsamplelooper_tilde.so => libs/armeabi-v7a/libsamplelooper_tilde.so
[arm64-v8a] SharedLibrary  : libsamplelooper_tilde.so
[x86] Install        : libsamplelooper_tilde.so => libs/x86/libsamplelooper_tilde.so
[x86_64] SharedLibrary  : libsamplelooper_tilde.so
[x86_64] Install        : libsamplelooper_tilde.so => libs/x86_64/libsamplelooper_tilde.so
[arm64-v8a] Install        : libsamplelooper_tilde.so => libs/arm64-v8a/libsamplelooper_tilde.so
make: Leaving directory `---/android/jni'

BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
14:38:23: Task execution finished 'buildNative'.

Unsatisfied link error on arm64 devices

I'm getting errors when initialising the library on arm64 devices (I have the Nexus 6P) and am getting the following error:

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.bytegeist.tonal.pro-1/lib/arm64, /data/app/com.myapp-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libpd.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:984)
at java.lang.System.loadLibrary(System.java:1530)
at org.puredata.core.PdBase.<clinit>(PdBase.java:55)
at org.puredata.core.PdBase.implementsAudio(Native Method)
at org.puredata.android.io.PdAudio.isRunning(PdAudio.java:122)
at org.puredata.android.io.PdAudio.initAudio(PdAudio.java:57)

I looked in the exploded aar folder and there are folders for armeabi, armeabi-v7a and x86 but I can't see folders for arm64 or any of the variants listed in the error. Is it possible to get a release with the native files compiled for arm64?

EDIT: it is possible to work around this by adding a few tweaks as outlined in this article but it is still just a workaround, ideally the library should be built with arm64 in mind

Subscribe (receive) in both java and c++?

I'm currently using a mix of c++ and java and I'm looking for a method of subscribing to PD receivers in both c++ code and java. Is there ideas on how I should go about that?

failing to run some externals

howdy, I've been testing libpd for android and some externals. I've managed to use pd's extra objects as well as a few objects from cyclone and also from another library of my own.

But the thing is that some externals will fail, and they're pretty simple so I can't see any reason why they fail, here's one I couldn't run, for instance: https://github.com/porres/pd-else/blob/master/classes/gbman~.c

What should I know or be careful about building external objects for android?

how can I get more information about my problem?

the object does compile and create and everything, I just do not hear any sound!

cheers

Target api 28

it may not support api 28. i have tried to build and run, but it doesnot output audio :(

Audio glitch on some devices (sample rate specific)

Case 1: Audio glitch on Xiaomi Redmi Note 4 (mido) if native sample rate

Xiaomi Note 4 reports 48 kHz as native sample rate. However, the playback crackles with pd-for-android (1.0.2 and the recent 1.1.0) when we use this sample rate.

This issue is reproducible through PdTest sample project on this device. Playback is fine with lower sample rates like 44.1 kHz.

This must be bug in libpd or pd-for-android since playback through oboe with native sample rate works fine without any glitches. This can be verified with hello-oboe sample project.

We have reason to believe that this is the case for all Xiaomi Marshmallow and newer devices.

Case 2: Audio glitch on samsung SM-G960F (samsung starlte) if 44.1 kHz

This is the reverse of case 1. This device works without audio glitch if native sample rate is used (48 kHz). However, if we use 44.1 kHz, we hear crackling.

Support pd patch encryption

I may sound paranoid. But I think it may be important that pd-for-android provide support for pd patch encryption. At the moment it is too easy to lift the patches. This is fine in the spirit of pure data's openness and the ability to learn from other's work. However, there are too many copy-cat apps on play store sometimes even imitating app name and logos. It is definitely an issue when using pd-for-android. (Not sure if this is an issue in the way iOS apps are developed with libpd.)

Apps encrypting patch file and decrypting prior to passing pd-for-android is not effective as the patch is simply visible from the file system. pd-for-android may be able to a better job for this. I wonder if it can do encryption during the compilation, decrypt at runtime, etc. Note, I am a novice on the topic of cryptography. I only understand the issue apps will have using pd-for-android.

I would just like to get the discussion started on this topic.

midi support?

I'm using LibPd which is awesome btw :) and I'm missing midi support. I read somewhere that is possible but not really working for me.
Any hint?

Firsts tests with pdforandroid - onServiceConnected is not executed

Dear friends.

I'm trying to drive a PD patch form android and I first tried to install the library. When I debug using logcats, the code into onServiceConnected is not executed. I use the last version of Android Studio.

I looked after that all the day and I didn't found nothing incorrect...

Here is the code

package com.example.test_pd_android;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.io.File;
import java.io.IOException;

import org.puredata.android.io.AudioParameters;
import org.puredata.android.service.PdService;
import org.puredata.android.utils.PdUiDispatcher;
import org.puredata.core.PdBase;
import org.puredata.core.utils.IoUtils;

import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.view.WindowManager;
import android.os.IBinder;
import android.util.Log;
import android.view.MotionEvent;

public class MainActivity extends AppCompatActivity {

    //---------------------------------------------Variables PD
    PdService pdService = null;
    PdUiDispatcher dispatcher;
    private final Object lock = new Object();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initPdService();
        Log.e("PDandroid", "onCreate");
    }

    private final ServiceConnection serviceConnection = new ServiceConnection() {

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            synchronized(lock) {

                Log.e("PDandroid", "onServiceConnected");

                pdService = ((PdService.PdBinder) service).getService();

                try {
                    Log.e("PDandroid", "InitPd");
                    initPd();
                    loadPatch();
                } catch (IOException e) {
                    Log.e("PDandroid", "Except");
                    Log.e("PDandroid", e.toString());
                    finish();
                }

            }

        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            // Never called
            Log.e("PDandroid", "onServiceDisconnected");
        }
    };

    /* Bind pd service */

    private void initPdService() {

        new Thread() {
            @Override
            public void run() {
                Log.e("PDandroid", "initPdService");

                bindService(new Intent(MainActivity.this, PdService.class),
                        serviceConnection, BIND_AUTO_CREATE);
            }
        }.start();
    }

    private void initPd() throws IOException {

        Log.e("PDandroid", "initPd");

        // Configure the audio glue
        int sampleRate = AudioParameters.suggestSampleRate();

        pdService.initAudio(sampleRate, 0, 2, 10.0f);

        pdService.startAudio(new Intent(this, MainActivity.class),
                R.drawable.icon, "TestPD", "Return to it");

        dispatcher = new PdUiDispatcher();
        PdBase.setReceiver(dispatcher);

    }

    private void loadPatch() throws IOException {

        Log.e("PDandroid", "loadPatch");

        /*

        if (pd == 0) {
            File dir = getFilesDir();
            IoUtils.extractZipResource(
                    getResources().openRawResource(
                            com.example.test_pd_android.R.raw), dir,
                    true);
            File patchFile = new File(dir, "test.pd");
            pd = PdBase.openPatch(patchFile.getAbsolutePath());

        }


         */
    }

}

And here is my settings file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28


    defaultConfig {
        applicationId "com.example.test_pd_android"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'org.puredata.android:pd-core:1.1.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

I joined here the full project...

test_PD_Android.zip

Hope you can help me to found an issue, best regards.

PdAudio::init() fails on specific devices

I have the following code to initialize PdAudio

    private void configureAudioGlue() throws IOException {
        AudioParameters.init(mContext);

        int sampleRate = AudioParameters.suggestSampleRate();
        final int inputChannels = AudioParameters.suggestInputChannels(); // or 1
        final int outputChannels = AudioParameters.suggestOutputChannels();
        final int ticksPerBuffer = 8; // ignored from android 2.3 / openSL
        final boolean restart = true;

        PdAudio.initAudio(sampleRate, inputChannels, outputChannels, 
                                          ticksPerBuffer, restart);
    }

I find that this fails with IOException on the following devices, as per my app's crash reports

  1. Lenovo Vibe P1– P1a42
  2. Lenovo A680– A680
  3. Samsung Galaxy Core Prime – SM-G360H
  4. Samsung I9505 Galaxy S4 – GT-I9505

I suspected the suggested sample rate may be incorrect, so tried with other known sample rates.
None of them work.

44100, 48000, 32000, 24000, 22050, 16000, 12000, 11025, 8000

PdService crashes when started in foreground on Android Oreo

The crash occured on a Pixel 2 with Android 8.1.0 .

The crash occurs with compileSdkVersion = 27 (not sure about previous versions however it didn't happen with 25 on Pixel 2)

Oreo notifications require a channel in order to work.
PdService will crash if started without it.
Adding a channelId to the foreground notification will not affect it.

Something like this should be added in PdService:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager notificationManager =
(NotificationManager) App.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = NOTIFICATION_CHANNEL_ID;
CharSequence channelName = App.getContext().getString(R.string.app_name);
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel notificationChannel = new NotificationChannel(channelId, channelName, importance);
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.WHITE);
notificationChannel.enableVibration(true);
if (notificationManager != null)
notificationManager.createNotificationChannel(notificationChannel);
}

example log from crashlytics:
Fatal Exception: android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=null pri=0 contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x42 color=0x00000000 vis=PRIVATE)

error: ... couldn't create

I'm trying to get a log printed of the tone of a signal played, so I am using the PdTest with a small diff to listen to the symbol 'pitch' and log it, and a small change to the .pd file to have the symbol sent pd image here.

When I press the play button in PdTest I get this output:

8 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print:  
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: bob~
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: 
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: error: ... couldn't create
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: fiddle version 1.1 TEST4
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: bonk version 1.5
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: pique 0.1 for PD version 23
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: 
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print:  
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: stdout
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: 
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: error: ... couldn't create
02-18 12:16:15.479 26321-26321/org.puredata.android.test I/PdUiDispatcher: print: PD_RUNS: 29.186

and my logs aren't printed.

I'm running it through AndroidStudio, on OSX 10.11.2 and on a HTC One m8 running Marshmallow.

No audio from App when "expr" used in patch.

I am to implement a peaking filter (using biquad~) given freq/q/gain.
The patch works fine in Pd using a .wav file to test the filter. However when using it with Android Studio, there is no sound output.
No errors are shown in Android Studio, the patch loads fine, just no sound.

If I take away the section of the patch which converts the f/q/g parameters into filter coefficients, and just give in 5 random coefficients, the patch works fine. However, as soon as I add in any "expr" oblect to my patch, no audio comes from the app.

Thus, I presume the issue is with the "expr" object as besides that, there isn't much else extra.
Is there anything specific which I would have to change to allow my Android Studio project to use "expr"?

I'm using pd-for-android by adding a dependency in my build.gradle (Module: app) file.
The targetsdkversion is 22.

Here is a link to my Android Studio project.
https://www.dropbox.com/s/l8cowlox1v0al79/LibPdBiquad.zip?dl=0

This is the Pd patch I'm trying to run.
image

Could you please clarify licensing requirements

Hi,
I'm about to release a small Android app which uses pd-for-android. The simplicity of using it today via JCenter is a bless compared to when I first used it backin the Eclipse days. Thanks for that!

I'm struggling a bit with correctly citing the license in the app. Since I'm including PdCore from JCenter I've started by citing https://github.com/libpd/pd-for-android/blob/master/PdCore/LICENSE.txt. Is that already enough or should I cite libpd's LICENSE.txt ( https://github.com/libpd/libpd/blob/master/LICENSE.txt ) as well, which BTW reads a bit different w.r.t. copyright than the copyright information in libpd's README.md ( https://github.com/libpd/libpd/blob/master/README.md ).

Thanks in advance,
Felix

Needs expr~ attribution

expr is LGPL licensed and requires attribution. Apps built with pd-for-android should include expr in their list of copyrights.

The pd-for-android release should make this clear. (In its Readme and Licenses?)

See question raised here: #39

Glitches caused by OpenSL ES with wrong buffer size?

Glitches caused by OpenSL ES with wrong buffer sizes?

I am building an app with a relatively large pd patch. It was working great on my Nexus 5 until I converted the patch to stereo, which led to twice of lots of things. Then glitches started happening. I do not think it is a performance issue, as the app runs fine on older hardware like the Samsung Galaxy Tab 10.1 (2011) and the Galaxy SIII.

I came across this article: Understanding Android audio towards achieving low latency response

duh. As mentioned before: larger values improve stability, while lower values lower latency. However, it's not just a matter of choosing the right size for the minimum amount of latency and maximum stability, but also making it a multiple of the devices native buffer size.

For instance : some devices may report a recommended 4800 samples per buffer-size, which is apart from being quite large, also an unusual number. By dividing using multiples of 4800 we can however reach a low, stable buffer size of 75 samples per buffer. Other devices may however report a recommended buffer size of 512 samples, the lowest usable buffer size ( when keeping the above rule of multiples in mind ) could be 64 samples. Using a value outside of the multiple range ( for instance using 75 samples per buffer on a device that requires 64 samples per buffer ) may cause glitches as occasionally the buffer callback is called twice per timeslice. This can go by unnoticed if you have CPU cycles to spare, but it's more likely that this will slowly but surely accumulate to a clusterfuck.

This rhymes very well with my experience.

When running libpd with opensl it seems like the buffer size always is 64.

When I do suggestOutputBufferSize(suggestSampleRate()) on the Nexus 5 I get 240. 240 is not a multiple of 64, and I get glitches. On a Honor 7 that I have tried, suggestOutputBufferSize(suggestSampleRate()) returns 960, which IS a multiple of 64, and there are no glitches. On the Galaxy SIII suggestOutputBufferSize(suggestSampleRate()) returns 1024, which is also a multiple of 64, and no glitches there either.

If I run the app at 44100 on the Nexus 5 there are no glitches (but AUDIO_OUTPUT_FLAG_FAST denied by client), but then there are glitches on the Honor 7. The Galaxy SIII is fine with both 44100 and 48000.

So my question is:

Could it be that the buffer size for opensl should be a multiple of what is returned by suggestOutputBufferSize(suggestSampleRate()) to achieve optimal performance? If yes: Would it be possible to modify pd-for-android, so that the audio buffer size could be set manually?

I realise that libpd can only process n ticks at a time, and that those should rather be 64 samples each. So in case of buffer size 240 one would have to process 4 ticks, which would end up with 256 samples, then send 240 of them to the soundcard and save 16 of them for the next cycle. It would be a bit complicated, but I have dug a bit around in z_jni_opensl.c and it seems like it should be possible.

But before I make the effort: Do you think it will solve the problem of glitches?

Thanks for any thoughts.

Fatal: clone into sumbodule path

I am getting a Failed to clone 'PdCore/jni/libpd' while trying to initialize and update the submodules, any idea what is wrong?

Compiling pd-for-android package

Hi everybody,

some problems appeared compiling pd-for-android at OS X 10.9.5. I would like to share all steps what I did.

1 - Download and follow the installation steps for pd-for-android.

2 - Add the ANDROID_HOME to bash_profile. Check the next discussion, at third response or follow the next instructions:

In Terminal:
    nano ~/.bash_profile 
Add lines:
    export ANDROID_HOME=/YOUR_PATH_TO/android-sdk
    export PATH=$ANDROID_HOME/platform-tools:$PATH
    export PATH=$ANDROID_HOME/tools:$PATH

Usage: Ctrl+O to write changes and Ctrl+X to close.

Check it worked:
    source ~/.bash_profile
    echo $ANDROID_HOME

NOTE: YOUR_PATH_TO refers to folder which Android SDK is located. (Look at: usr/local/Cellar/android).

3 - Go to PureCore/jni/libpd/pure-data and do:
git submodule init
git submodule update

NOTE: this step is weird but for me it vital to compile PdCore library.

4 - Go back to pd-for-android/ directory and run ./gradlew PdCore:assembleRelease

NOTE: Install all the android sdk versions required by the process until to get BUILD SUCCESSFUL MESSAGE.

5 - Finally, open Android Studio and pick up Import gradlew project with PdTest. Gradlew should be sync by grawdle wrapper.

6 - Run pd-for-android examples and enjoy.

Thanks,

XL

Include header files in AAR required for building custom externals

pd-for-android currently includes libpd.so and native binaries of standard externals. However, the user of pd-for-android aar file wants to write custom externals, m_pd.h is also required. Such headers required for building custom externals can be packaged in AAR.

PdTest gives a nice example of custom external, but it does not depend on aar file which is what a typical user of this library will have.

Documenting the approach I use to build custom external here (Hope it helps someone. Suggestions and corrections are welcome).

Custom External: Compilation

Compilation of custom external requires m_pd.h in the include path. To achieve this

  1. git clone https://github.com/libpd/libpd
  2. Refer the clone header path in CMakeLists.txt of the custom external module like this. (I have android studio module for custom external and I use CMake for building c/c++ stuff for android as per current recommendation by Google)
cmake_minimum_required (VERSION 3.4.1)

set (SRC_PATH src/main/cpp)
link_directories ("libs/jni/${ANDROID_ABI}")

include_directories ("../../lib/libpd/pure-data/src")
add_library (myexternal_tilde SHARED ${SRC_PATH}/myexternal~.c)
target_compile_options (myexternal_tilde PRIVATE -std=c11 -DPD -O3)
target_link_libraries (myexternal_tilde pd)

Custom External: Linking

In order to make linking succeed, I pull libpd.so for different architectures from pd-for-android aar like this:

repositories {
    flatDir {
        dirs 'libs'
    }
}

configurations {
    aarjni {
        description = "copies jni directory from aar to libs"
        visible = false
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    aarjni "org.puredata.android:pd-core:$rootProject.ext.pdForAndroidVersion@aar"
}

// TODO ensure `cleanup` removes files copied by this task
// TODO make this task and configuration available to all projects
task extractJniFromAar {
    configurations.aarjni.resolvedConfiguration.resolvedArtifacts.each { artifact ->
        inputs.file artifact.file
        //noinspection UnnecessaryQualifiedReference
        def zipFile = new java.util.zip.ZipFile(artifact.file)
        zipFile.entries().each { entry ->
            if (!entry.isDirectory()) {
                outputs.file entry.getName()
            }
        }
    }
    doLast {
        inputs.files.each { zip ->
            copy {
                from zipTree(zip)
                into 'libs'
                include '/jni/**'
            }
        }
    }
}
preBuild.dependsOn extractJniFromAar

Conclusions

As you can see, compilation requires header files from pure data source which we have to pull manually. This makes compilation work, but there may be mismatch between the header files from libpd repository and native libs included in pd-for-android. I learned somewhere that aar file which carry native libraries can package header files as well.

Additionally, it would be great if pd-for-android can help further simplify this process.

PdCore:javadoc task fails

This prevents a clean bintrayUpload from working. Remove javadoc artiffact and related tasks?

>gradlew PdCore:javadoc
:PdCore:javadoc
PdCore\src\org\puredata\android\io\AudioWrapper.java:12: error: cannot find symbol
import org.puredata.android.service.R;
                                   ^
  symbol:   class R
  location: package org.puredata.android.service
PdCore\src\org\puredata\android\midi\MidiToPdAdapter.java:12: error: package com.noisepages.netto
yeur.midi does not exist
import com.noisepages.nettoyeur.midi.MidiReceiver;
                                    ^
PdCore\src\org\puredata\android\midi\MidiToPdAdapter.java:19: error: cannot find symbol
public class MidiToPdAdapter implements MidiReceiver {
                                        ^
  symbol: class MidiReceiver
PdCore\src\org\puredata\android\midi\PdToMidiAdapter.java:12: error: package com.noisepages.netto
yeur.midi does not exist
import com.noisepages.nettoyeur.midi.MidiReceiver;
                                    ^
PdCore\src\org\puredata\android\midi\PdToMidiAdapter.java:21: error: cannot find symbol
        private final MidiReceiver receiver;
                      ^
  symbol:   class MidiReceiver
  location: class PdToMidiAdapter
PdCore\src\org\puredata\android\midi\PdToMidiAdapter.java:29: error: cannot find symbol
        public PdToMidiAdapter(MidiReceiver receiver) {
                               ^
  symbol:   class MidiReceiver
  location: class PdToMidiAdapter
PdCore\src\org\puredata\android\service\PdService.java:33: error: package android.support.v4.app
does not exist
import android.support.v4.app.NotificationCompat;

44.1KHz sampling rate is unsustainable

I compiled and ran PdTest on a capable android device - Micromax A116 Canvas HD - which is a 1GHz quad core droid phone running Jelly Bean. Only the 22.05KHz sampling rate is sustainable without breaks. Any higher sampling rate results in breaks in the audio. The device is performant with other apps.

Perhaps default buffer sizes in PD need to be larger?

Add reference for API 23 permissions handling

Hi
I have the next issue on Android 6.0 when is trying to run the app with libpd, as far as i know the support required to compile the libpd with the latest NDK to avoid the text relocation

E/AndroidRuntime(19967): java.lang.UnsatisfiedLinkError: dlopen failed: /lib/arm/libpd.so: has text relocations

Wheezes when try to play two sounds at the same time

I have two receivers in pd file. Both of them play different wav files. When I send bang (PdBase.sendBang("...")) to the first receiver, and while it's playing wav file I send bang to the second receiver I get wheezes. Looks like sound overloading when libpd plays 2 sound at the same time.
I've tested on Nexus 5X (Android O), Nexus 6P (Android N), Galaxy J7 2016 (Android M)

Audio glitches when screen is not being touched

When I try to play a steady frequency, after few seconds there are noticeable breaks in the audio, even while screen is still on.

Interestingly, when I keep tapping on the screen, there are no breaks in the audio.

I tested this with couple of Nexus 4 devices with Lollipop (stock android and CyanogenMod). On the other hand, I don't get this problem in emulator.

I was assuming pd-for-android would retain audio thread priority for the app.

By the way, there is no problem with simpler patches. My patch involved some reasonably heavy calculation, getting rid of this part from the patch avoided this problem. As I mentioned, even if that calculation part is kept and the screen kept tapped, no problem of audio breaks.

I am using v1.0.0, native sampling rate, 2 output channels, 1 input channel, and PdService.

Kotlin support

Is there a way to use this with Kotlin? (Specifically for a Flutter project using Kotlin.)

Add Proguard Rules to Wiki and Sample Apps

Hi, I was having a problem when I tried to create an signed APK with "minifyEnabled true" when using pd-for-android directly as a dependency in the file "app>build.gradle".
Sometimes the release don't compiles and sometimes compiles but crash on app start.

This is the way I'm doing:

dependencies {
    ...
    ...
    compile 'org.puredata.android:pd-core:1.0.0-rc4'
}
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

I've solved the problem with the following procedure:
In proguard-rules.pro file, insert the following line to skip class regarding the PureData:

-keep class org.puredata.** { *; }

Using this my app.apk size reduced from 3.5Mb to 2.5Mb.

This is the correct way to do this? Anyone have the same problem?

Sorry if here isn't the right place to post this. But I take a lot o time to handle this and I want to contribute with this great project.
Thank you

Investigate NDK warnings when building externals

We should investigate why the NDK gives these warning when ScenePlayer and PdTest are build:

Android NDK: WARNING:pd-for-android/ScenePlayer/jni/Android.mk:rj_accum: non-system libraries in linker flags: -lpd
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the current module
[...]

Reported by @joebowbeer : #31 (comment)
Related: http://android.mk/

Crash on pixels with Android 8.1 and any devices with Android P in sys_startgui

There is a problem with Pixel XL / Pixel 2 XL / Pixel / Pixel 2 after last Android security update.

During initialization process in https://github.com/libpd/libpd project there are function calls libpd_init -> sys_startgui -> setuid. Calling setuid is prohibited in Android starting Oreo.
Looks like it was already fixed in libpd/libpd@b8b972a#diff-77187871d46f57651997feb0748feffdL90.
The same behaviour was detected on Android P Preview.

Stacktrace:

#00  pc 0000000000054bc8  /system/lib/libc.so (setuid+12)
  #01  pc 000000000004c343  /data/app/SOMEAPP/lib/arm/libpd.so (sys_startgui+1094)
  #02  pc 0000000000069b21  /data/app/SOMEAPP/lib/arm/libpd.so (libpd_init+152)
  #03  pc 000000000006a4ff  /data/app/SOMEAPP/lib/arm/libpd.so (libpd_queued_init+142)
  #04  pc 0000000000003b9d  /data/app/SOMEAPP/lib/arm/libpdnativeopensl.so (Java_org_puredata_core_PdBase_initialize+4)

gradle build not finding support libraries

When I run
./gradlew PdCore:assembleRelease
I get:

A problem occurred configuring project ':CircleOfFifths'.
A problem occurred configuring project ':PdCore'.
Could not resolve all dependencies for configuration ':PdCore:_debugCompile'.
> Could not find com.android.support:support-v4:23.1.0.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-v4/23.1.0/support-v4-23.1.0.pom
https://jcenter.bintray.com/com/android/support/support-v4/23.1.0/support-v4-23.1.0.jar
file:/Users/diglesia/android-sdks/extras/google/m2repository/com/android/support/support-v4/23.1.0/support-v4-23.1.0.pom
file:/Users/diglesia/android-sdks/extras/google/m2repository/com/android/support/support-v4/23.1.0/support-v4-23.1.0.jar
Required by:
org.puredata.android:PdCore:1.0.0

See attached image for the state of my android-sdks folder. The support libraries, as installed by current Android Studio SDK, are in
android-sdks/extras/android/support
(wheras android-sdks/extras/google/m2repository/com/android/support is empty)

Please advise! Thanks

screen shot 2016-01-31 at 12 27 06 pm

Fiddle / pd externals not working on arm64-v8a devices

I have a simple patch using fiddle which looks like this:

screen shot 2015-12-19 at 3 26 50 pm

However, when I attempt to use this patch with pd-for-android, I get the following error:

12-19 15:58:15.426 30182-30182/com.deepkanwal.fiddletest I/PdUiDispatcher: print: 
12-19 15:58:15.426 30182-30182/com.deepkanwal.fiddletest I/PdUiDispatcher: print:  
12-19 15:58:15.426 30182-30182/com.deepkanwal.fiddletest I/PdUiDispatcher: print: fiddle~
12-19 15:58:15.426 30182-30182/com.deepkanwal.fiddletest I/PdUiDispatcher: print:  
12-19 15:58:15.426 30182-30182/com.deepkanwal.fiddletest I/PdUiDispatcher: print: 2048
12-19 15:58:15.426 30182-30182/com.deepkanwal.fiddletest I/PdUiDispatcher: print: 
12-19 15:58:15.426 30182-30182/com.deepkanwal.fiddletest I/PdUiDispatcher: print: error: ... couldn't create
12-19 15:58:15.426 30182-30182/com.deepkanwal.fiddletest I/PdUiDispatcher: print: error: signal outlet connect to nonsignal inlet (ignored)
12-19 15:58:15.426 30182-30182/com.deepkanwal.fiddletest I/PdUiDispatcher: print: verbose(4): ... you might be able to track this down from the Find menu.

The patch works fine when running via Pure Data.

I am using PDService, which from what I understand, will handle installing standard externals.

Here's a link to the activity in which I'm doing all my pure data logic right now: https://github.com/deepkanwal/pure-data-fiddle-test/blob/master/app/src/main/java/com/deepkanwal/fiddletest/FiddleTest.java

Here's a link to a simple test project which I'm using to try loading fiddle: https://github.com/deepkanwal/pure-data-fiddle-test

Any ideas as to what the issue might be?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.