0

I am using a patch to implement a peaking filter (using biquad~) given freq/q/gain.

The patch works fine in Pd, however when using it with Android Studio, I don't get sound. No errors are shown in Android Studio, the patch loads fine, just no sound.

If I take away the section of the patch converting the f/q/g parameters into filter coefficients, and just give in 5 random coefficients, the patch works fine.

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 add to my Android Studio project due to using expr?

Biquad Patch with Expr

This patch doesn't work.

Biquad Patch without Expr

This patch does work.

My java file looks like this:

package com.example.mark.pdaudioio;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.Switch;
import android.widget.TextView;

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

import java.io.File;
import java.io.IOException;

public class MainActivity extends AppCompatActivity {

    TextView volumeTextViewJava;
    SeekBar volumeSeekBarJava;
    int volume = 0;

    private PdUiDispatcher dispatcher;

    private void initPD() throws IOException{
        int sampleRate = AudioParameters.suggestSampleRate();
        int inpch = AudioParameters.suggestInputChannels();
        PdAudio.initAudio(sampleRate, inpch, 2, 8, true);
        dispatcher = new PdUiDispatcher();
        PdBase.setReceiver(dispatcher);
    }

    private void initGUI(){
        Switch onOffSwitch = (Switch) findViewById(R.id.onOffSwitch);
        onOffSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                float val = (isChecked) ? 1.0f : 0.0f;
                PdBase.sendFloat("onOffPD",val);

            }
        });

        volumeTextViewJava = (TextView) findViewById(R.id.volumeTextView);

        volumeSeekBarJava = (SeekBar) findViewById(R.id.volumeSeekBar);
        volumeSeekBarJava.setMax(100);
        volumeSeekBarJava.incrementProgressBy(1);
        volumeSeekBarJava.setProgress(0);
        volumeSeekBarJava.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            public void onProgressChanged(SeekBar seekBar, int volProgress, boolean fromUser) {
                volume = volProgress;
                float volumeFloat = (float) volume;
                PdBase.sendFloat("volumePD", volumeFloat);
                volumeTextViewJava.setText("vol: " + volProgress);

            }
            public  void onStartTrackingTouch(SeekBar seekBar) {

            }
            public  void onStopTrackingTouch(SeekBar seekBar) {
            }
        });
    }

    private void loadPDPatch() throws IOException{
        File dir = getFilesDir();
        IoUtils.extractZipResource(getResources().openRawResource(R.raw.simplepatch),dir,true);
        File pdPatch = new File(dir, "Biquad_WithExpr.pd");
        PdBase.openPatch(pdPatch.getAbsolutePath());

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try{
            initPD();
            loadPDPatch();

        }catch (IOException e){
            finish();
        }

        initGUI();
    }

    @Override
    protected void onResume(){
        super.onResume();
        PdAudio.startAudio(this);
    }

    @Override
    protected void onPause(){
        super.onPause();
        PdAudio.stopAudio();
    }
}

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

Any help at all is greatly appreciated!!

markos14
  • 78
  • 11

1 Answers1

1

I've had similar issues when using libPD within both Android and iOS. It looks like most of your expressions could be handled using native pd-vanilla objects (but it will be a bit more verbose), so recoding the expressions would likely fix the issue. If you're not already doing so, it's good practice to test your libPD patches via PD-Vanilla rather than the PD-extended or PD-L2Ork.

Joe P.
  • 73
  • 8