0

I am new to android and i just want to create a dj player. but for that the starting step is mixing two files. The rough code for that i found on the following link but in that i did not understand how to code for buildShortArray(music1).

I already tried this code but got stuck in the above mentioned method's code.

thank you in advance for help.

Docs here:Mix two files audio wav on android use short array

Community
  • 1
  • 1
ank
  • 55
  • 1
  • 7

1 Answers1

0

The code from the link does not show the buildShortArray method.

You need to transform List<Short> into array short[]:

List<Short> music1 = ...;
short[] arrayMusic1 = buildShortArray(music1);

You could write the method buildShortArray like this:

public short[] buildShortArray(List<Short> list) {

    short[] array = new short[list.size()];

    for(int i = 0; i < list.size(); i++) {
        array[i] = list.get(i);
    }

    return array;
}

However, i'd like to warn you, copy-pasting code is never a good idea.

nillas
  • 431
  • 3
  • 4