我有一个简单的 libPd 项目。现在,我已经下载了一个.wav
文件,我想播放它而不是我拥有的纯数据文件。
有可能这样做吗?
如果是这样,我该怎么做?
这是我的项目:
public class MainActivity extends AppCompatActivity {
private Button kickButton, bassButton;
private PdUiDispatcher dispatcher;
private boolean isClicked;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
kickButton = (Button) findViewById(R.id.kickButton);
bassButton = (Button) findViewById(R.id.bassButton);
int sampleRat = AudioParameters.suggestSampleRate();
try {
PdAudio.initAudio(sampleRat,0,2,8,true);
dispatcher = new PdUiDispatcher();
PdBase.setReceiver(dispatcher);
File dir = getFilesDir();
IoUtils.extractZipResource(getResources().openRawResource(R.raw.simplepatch),dir,true);
File pdPatch = new File(dir, "simplepatch.pd");
PdBase.openPatch(pdPatch.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
kickButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isClicked = !isClicked;
float val = (isClicked) ? 1.0f : 0.0f;
PdBase.sendFloat("onOff", val);
}
});
}
@Override
protected void onResume() {
super.onResume();
PdAudio.startAudio(this);
}
@Override
protected void onPause() {
super.onPause();
PdAudio.stopAudio();
}
}