/AudioGen4MusicSegmentation/src/main/java/umslt/agmsa/Expander.java
Java | 70 lines | 53 code | 8 blank | 9 comment | 2 complexity | a0e177a8eff78d13502099e89509125f MD5 | raw file
Possible License(s): BSD-2-Clause
- package umslt.agmsa;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.Properties;
- import umslt.agmsa.util.Exec;
- public class Expander {
- private String sectionsDirectory;
- private final Integer secTimeInSec;
- private final String outputfile;
- /**
- * @param totalTimeInSeconds
- * @param forceallsections
- * @param forceonepersection
- */
- public Expander(String sectionsDirectory,
- String outputfile, Integer secTimeInSec) {
- this.sectionsDirectory = sectionsDirectory;
- this.outputfile = outputfile;
- this.secTimeInSec = secTimeInSec;
- }
-
- public void run() throws Exception {
- RandomSection rndSection = new RandomSection(this.sectionsDirectory, true, -1);
- createScoreFile(rndSection);
- }
- private void createScoreFile(RandomSection rndSection) throws Exception, IOException {
- int len = rndSection.sections.length;
- while(len-- > 0) {
- String nextSection = rndSection.nextSection(0, secTimeInSec);
- FileWriter fw = null;
- try {
- //write score file
- fw = new FileWriter(outputfile + "#"+ len + ".sco");
- fw.write(rndSection.getTableDefinitions());
- //clear table names
- rndSection.usedTableDefinitions.clear();
- fw.write(nextSection.toString());
- fw.flush();
- } finally {
- if (fw != null)
- fw.close();
- }
- //render wav file
- Exec.execPrintWait("csound -d -W -o " + outputfile + "#"+ len + ".wav bricolage.orc " + outputfile + "#"+ len + ".sco");
- //create transition file
- }
- }
-
- public static void main(String[] args) {
- Properties prop = new Properties();
- try {
- prop.load(new FileInputStream(new File("./bricolage.properties")));
- String sectionsDirectory = prop.getProperty("wav.dir");
- Integer secTimeInSec = new Integer(prop.getProperty("force.sectime"));
- String outputfile = prop.getProperty("output.file");
- Expander main = new Expander(sectionsDirectory, outputfile, secTimeInSec);
- main.run();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }