Closed markos14 closed 8 years ago
Did you include and call the .c externals, i.e. expr? That would be the first place I'd look. I tried your link, but it wasn't valid on my end.
On Tue, Jul 19, 2016 at 4:50 PM, markos14 notifications@github.com wrote:
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 http://url
This is the Pd patch I'm trying to run. [image: image] https://cloud.githubusercontent.com/assets/18605266/16970395/ac02a5b2-4e13-11e6-9473-4b89f101c410.png
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/libpd/pd-for-android/issues/52, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNIWjluIfuSRAWaHYZJ5xZSGd587QUVks5qXWKugaJpZM4JQSwK .
@geeetarguy Sorry about that.. Try this https://www.dropbox.com/s/l8cowlox1v0al79/LibPdBiquad.zip?dl=0
But, no is the answer, I haven't included and called the .c externals! I'm new to Android development and just presumed that if "expr" works in Pd Vanilla, that it would work straight off with libpd. Looking now, I see that expr.dll is in the extras folder in pd-extended.
Very sorry for wasting your time, but where and how do I include and call the .c external for expr?
Also, does this mean I can't build pd-for-android by the method of simply adding the dependency to my build.gradle file if I need to use "expr"?
Here's an example in Objective-C:
https://ccrma.stanford.edu/wiki/LibPD_and_externals
Pretty sure that the calls are basically the same between Android and iOS. I'd highly recommend Peter Brinkman's book Making Musical Apps. Well worth a read. He has Java and Objective-C examples back to back which really show the in's and out's of the library. I'm positive that there's an Android example in the pd-for-android Github page, though I couldn't find it quickly...it's there somewhere, just Google away.
Best of luck.
On Tue, Jul 19, 2016 at 5:30 PM, markos14 notifications@github.com wrote:
Sorry about that.. Try this https://www.dropbox.com/s/l8cowlox1v0al79/LibPdBiquad.zip?dl=0
But, no is the answer, I haven't included and called the .c externals! I'm new to Android development and just presumed that if "expr" works in Pd Vanilla, that it would work straight off with libpd. Looking now, I see that expr.dll is in the extras folder in pd-extended.
Very sorry for wasting your time, but where and how do I include and call the .c external for expr?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/libpd/pd-for-android/issues/52#issuecomment-233806426, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNIWjp3VIZ7Agk9tfpWSpO-alR5yn26ks5qXWw8gaJpZM4JQSwK .
@geeetarguy Great, thanks for your help and time! Found the example in PdTest of including and calling a "helloworld.c" external. That has already answered my question of being able to use libpd just by adding a dependency to my build.file or not... The answer is not if I need to add expr as an external (I think). I am getting my head around the process (add .c file to jni folder, include the .c file in the Android.mk file and then initialize it in my java file.) I presume that the vexpr.c file included in the jni folder of PdCore is the c file I'm looking for.
I'm slightly confused as the answer to this issue seems to suggest that expr should already be included? https://github.com/libpd/pd-for-android/issues/38
@markos14 If you are using PdAudio, instead of PdService, you have to explictly load the externals after initAudio(). Here is the code for that
private void loadStandardExternals() throws IOException {
File filesDir = getFilesDir();
IoUtils.extractZipResource(getResources().openRawResource(R.raw.extra_abs), filesDir, true);
PdBase.addToSearchPath(filesDir.getAbsolutePath());
String stdExternalsPath = "/data/data/" + getPackageName() + "/lib";
PdBase.addToSearchPath(stdExternalsPath);
}
On the other hand, if you are using PdService, there is no need to do this since the standard externals are automatically loaded.
@rpattabi I'm using PdAudio, so loaded the externals using the code above. I can see expr being compiled in my gradle console, and the gradle is building without any errors with the added code, but still no audio when expr is used in the patch. There is a warning about expecting an unsigned int in the expr.c code, but that's all.
This is my java file..
package com.example.mark.pdbiquad;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.Switch;
import org.puredata.android.io.AudioParameters;
import org.puredata.android.io.PdAudio;
import org.puredata.core.PdBase;
import org.puredata.core.utils.IoUtils;
import java.io.File;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
private void initPD() throws IOException{
int sampleRate = AudioParameters.suggestSampleRate();
int inputCh = AudioParameters.suggestInputChannels();
PdAudio.initAudio(sampleRate,inputCh,2,8,true);
}
private void loadExternals() throws IOException {
File filesDir = getFilesDir();
IoUtils.extractZipResource(getResources().openRawResource(R.raw.extra_abs),filesDir,true);
PdBase.addToSearchPath(filesDir.getAbsolutePath());
String stdExternalsPath = "/data/data" + getPackageName() + "/lib";
PdBase.addToSearchPath(stdExternalsPath);
}
private void initGUI(){
Switch filterSwitchJava = (Switch) findViewById(R.id.filterSwitch);
filterSwitchJava.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
float val = (isChecked) ? 1.0f : 0.0f;
PdBase.sendFloat("filterSwitchPD", val);
}
});
}
private void loadPdPatch()throws IOException {
File dir = getFilesDir();
IoUtils.extractZipResource(getResources().openRawResource(R.raw.simplepatch),dir,true);
File pdPatch = new File(dir, "simplepatch.pd");
PdBase.openPatch(pdPatch.getAbsolutePath());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try{
initPD();
loadExternals();
loadPdPatch();
}catch (IOException e){
finish();
}
initGUI();
}
@Override
protected void onResume(){
super.onResume();
PdAudio.startAudio(this);
}
@Override
protected void onPause(){
super.onPause();
PdAudio.stopAudio();
}
}
I presume its something to do with my build.gradle file This is what is looks like at the moment.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.mark.pdbiquad"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(':PdCore')
}
Any ideas? My frustration is getting the best of me as I've spent days trying to get expr to work at this point.
All but one of the examples in this repo are using PdService. Any reason not to follow suit?
Also, I notice that when PdService is used, for example in PdTest, the order of initialization is something like the following:
Which is a different order than in your app. I wonder if this is relevant.
I do think that switching to PdService is likely to work.
I am also not seeing what is wrong with the code. Some pointers though
compile 'org.puredata.android:pd-core:1.0.1'
instead of compile project(':PdCore')
Good luck.
Just to inform ye, I could not figure out how to get Expr working with PdAudio for some reason, even after trying all the above suggestions. I swapped to PdService and it works fine without any extra work to add the externals, etc as its done automatically as ye rightly stated. I was always going to have to move to PdService as I need more than 1 activity, but I wanted to get it working first with PAudio.
Bit of a follow-on question, is there any way of routing all audio from the phone (calls, music player, games, etc.) through the app? The app I designed is essentially a parametric EQ which takes input from the mic, now I want all the audio from the phone to pass through the EQ before being passed to the speakers. I have struggled to find any resources on it. I'd imagine mediaRouter and audioFocus are used, but I can't find any examples of using it in such a way! Any hints?
For phone calls and perhaps other sources, you could try MediaRecorder
https://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html
@markos14 I'm closing this one for now, as it sounds like your issue was resolved. Feel free to re-open if you think this is a problem that should be solved in the pd-for-android library.
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.