Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/main/java/com/music/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.nio.file.Files;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -234,7 +235,7 @@ public byte[] toMp3(byte[] midi, String wavPath) throws Exception {
try {
File wav;
if (wavPath == null) {
wav = File.createTempFile("gen", ".wav");
wav = Files.createTempFile("gen", ".wav").toFile();
} else {
wav = new File(wavPath + "/gen.wav");
}
Expand All @@ -253,7 +254,7 @@ public byte[] toMp3(byte[] midi, String wavPath) throws Exception {
// audio.setSamplingRate(20000);
attrs.setAudioAttributes(audio);
attrs.setThreads(1);
File mp3 = File.createTempFile("gen", ".mp3");
File mp3 = Files.createTempFile("gen", ".mp3").toFile();
encoder.encode(wav, mp3, attrs);
logger.info("wav2mp3 conversion took: " + (System.currentTimeMillis() - start) + " millis");
if (wavPath == null) {
Expand Down Expand Up @@ -493,4 +494,4 @@ public static void loadSoundbankInstruments(Synthesizer synthesizer) {
synthesizer.loadAllInstruments(soundbank);
}
}
}
}
5 changes: 3 additions & 2 deletions src/main/java/com/music/service/ManagementService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -129,7 +130,7 @@ public void fillVariation() {
try {
InputStream is = pieceService.getPieceMidiFile(piece.getId());
byte[] midi = IOUtils.toByteArray(is);
File tmp = File.createTempFile("tmp", "mid");
File tmp = Files.createTempFile("tmp", "mid").toFile();
FileUtils.writeByteArrayToFile(tmp, midi);
Score score = new Score();
Read.midi(score, tmp.getAbsolutePath());
Expand All @@ -143,4 +144,4 @@ public void fillVariation() {

}
}
}
}