コード例 #1
0
ファイル: Editor.java プロジェクト: jakubszlendak/jtunes
  /**
   * 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();
    }
  }
コード例 #2
0
ファイル: Editor.java プロジェクト: jakubszlendak/jtunes
  /**
   * This function loads the .WAV song which is to be edited into the RAM memory
   *
   * @param fileToOpen - the file to be edited.
   */
  public void loadSong(File fileToOpen) {
    file = fileToOpen;
    int fileLength = (int) file.length();
    rawData = new byte[fileLength];
    try {
      fileInputStream = new FileInputStream(file);
      dataIn = new BufferedInputStream(fileInputStream);
      for (int i = 0; i < fileLength; ++i) rawData[i] = (byte) dataIn.read();
      wavTagReader = new WavTagReader(this.rawData);
      wavTagReader.readHeader();

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
コード例 #3
0
ファイル: Editor.java プロジェクト: jakubszlendak/jtunes
  /**
   * 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();
    }
  }