RNBO Load Buffer problem on iPhone

π΅π“‡π“Šπ“ƒπ’Ά π’’π“Šπ’Άπ“‡π“ƒπ’Ύπ‘’π“‡π’Ύ 's icon

Dear Community,

I am currently working on a project where I am writing code in RNBO+ Javascript (P5js) that fetches a .mp3 audio file using an HTTP request and then loads it into a buffer object.

While the code works really well on desktop, I am facing some issues when it comes to loading the buffer object on mobile devices.

In particular, the code works erratically on iPhones where the buffer sometimes loads successfully while other times it stays queued or starts reloading, and then the browser can't open the page. After debugging chrome for iOS, I have identified that there is an issue while setting the buffer in the device. "device.setDataBuffer()"

I am reaching out to the community for help in resolving this issue. If anyone has any suggestions or ideas on how to fix this, I would greatly appreciate it.

Here is the link to the full code.

Max Patch
Copy patch and select New From Clipboard in Max.

Here is Javascript RNBO side:

async function createRNBO(){

  const patchExportURL = "export/"+card.engine;

  // Create AudioContext
  let WAContext = window.AudioContext || window.webkitAudioContext;
  context = new WAContext();
  
  let rawPatcher = await fetch(patchExportURL);
  let patcher = await rawPatcher.json();
  device = await RNBO.createDevice({ context, patcher }); // seems we need to access the default exports via .default

  device.node.connect(context.destination);
/*
  const param = device.parametersById.get("audioLevel");

  param.changeEvent.subscribe((v) => {
    wsize = v;
  });*/
  print ("I am A1")

      loadAudioBuffer(context);

        // Connect With Parameters

         paramX = device.parametersById.get("paramX");
         paramY = device.parametersById.get("paramY");
         paramZ = device.parametersById.get("paramZ");
         print ("I am A2")


}


async function loadAudioBuffer(_context){
  loadingAudio(1);

  context = _context; 
  // Load our sample as an ArrayBuffer;
  const fileResponse = await fetch(card.filename);
  const arrayBuf = await fileResponse.arrayBuffer();
  print ("I am 1")

  // Decode the received Data as an AudioBuffer
  const audioBuf = await context.decodeAudioData(arrayBuf);
  print ("I am 2")


  // Set the DataBuffer on the device
  device.setDataBuffer("world1", audioBuf);
  print ("I am 3")

  loaded(); 
  print ("I am 4")
 
}
tomme's icon

I have the same problem. My patch works on desktop but on mobile (iPad and iPhone) it works after a long loading time and not always starts working.

π΅π“‡π“Šπ“ƒπ’Ά π’’π“Šπ’Άπ“‡π“ƒπ’Ύπ‘’π“‡π’Ύ 's icon

Hello,

After further investigation, I've discovered that this issue affects all mobile devices and is directly related to the size-duration of the audio buffer. Specifically, using larger audio files causes the buffer object to fail to load or start reloading, resulting in unstable performance on all devices. However, I've found that using shorter audio files results in much more stable playback across all devices.

I'm hoping to find a solution to this issue and would greatly appreciate any suggestions or ideas on how to fix this problem.

Francisco Ojeda's icon

Hey Bruna, did you find how long is the limit the audio files can be without causing problems?

π΅π“‡π“Šπ“ƒπ’Ά π’’π“Šπ’Άπ“‡π“ƒπ’Ύπ‘’π“‡π’Ύ 's icon

hEy Fransisco, It’s been a long time since the last time I tested this, what i understood is that the maximum time depends on the browser and device you are using, so there’s no one rule fits all.

In that moment I decided to work with files no longer than 5min.

What is your experience?