Example #1
0
  /**
   * This function saves given array with WAV song to the file with given filepathh
   *
   * @param filePath - the path to the file where the song is to be saved
   * @param wavSong - the array containing song raw data
   */
  public void saveSong(String filePath, byte wavSong[]) {
    FileOutputStream outputStream = null;
    try {
      outputStream = new FileOutputStream(filePath);
      outputStream.write(wavSong);
      outputStream.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Example #2
0
  /**
   * This function saves on the hard disk the edited .WAV
   *
   * @param filePath - the path to the directory, where the song is to be saved and the song name
   */
  public void saveSong(String filePath) {
    FileOutputStream outputStream = null;
    try {
      if (filePath.endsWith("mp3")) {
        outputStream = new FileOutputStream("temp.wav");
        outputStream.write(this.rawData);
        outputStream.close();
        convertWavToMP3("temp.wav", filePath);
      } else if (filePath.endsWith("wav")) {
        outputStream = new FileOutputStream(filePath);
        outputStream.write(this.rawData);
        outputStream.close();
      }

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }