I know that adding an option to create/import/export .cue files has been a pretty big feature request for Audacity. Anyway, I've created a Java program to convert .txt Audactiy label files to .cue files.
The program is available here - http://sourceforge.net/projects/label2cue.
The main portion of the code is the following:
Code: Select all
public static void createCueFile() throws IOException
{
String filename_final_truncated = "";
try
{
filename_final_truncated = filename_final.substring(0,filename_final.length()-4);
}
catch (StringIndexOutOfBoundsException h)
{
dir.setText("Please select a file first");
}
BufferedWriter output = new BufferedWriter(new FileWriter(filename_final_truncated + ".cue"));
BufferedReader getData = new BufferedReader(new FileReader(dir_final+"/"+filename_final));
ArrayList dataList = new ArrayList();
String str=null;
while((str = getData.readLine()) != null)
dataList.add(str);
String tempString = null;
output.write("FILE "" + filename_final_truncated + """ + " BINARY");
output.newLine();
// Commented out areas could be useful for debugging
for(int x=0;x<dataList.size();x++)
{
String temp = getCue(dataList, x);
if(x<=8)
{
System.out.println(" TRACK 0"+(x+1)+" AUDIO");
output.write(" TRACK 0"+(x+1)+" AUDIO");
output.newLine();
}
else
{
System.out.println(" TRACK "+(x+1)+" AUDIO");
output.write(" TRACK "+(x+1)+" AUDIO");
output.newLine();
}
if(prefix.equals(""))
{
prefix = Double.toString(tok1);
}
System.out.println(" TITLE "" + prefix + """);
output.write(" TITLE "" + prefix + """);
output.newLine();
System.out.print(" INDEX 01 " + temp);
output.write(" INDEX 01 " + temp);
if((x+1)<dataList.size())
{
output.newLine();
System.out.println();
}
}
output.close();
dir.setText("File converted and saved in " + dir_final);
}
public static String getCue(ArrayList data, int index)
{
String cueFinal = "";
String trackadd = "";
String lAdd_min = "";
String lAdd_sec = "";
String lAdd_frame = "";
StringTokenizer Tok = new StringTokenizer((String)data.get(index)," ");
tok1 = Double.parseDouble(Tok.nextToken());
prefix = "";
try
{
prefix = Tok.nextToken();
}
catch (NoSuchElementException e)
{
}
if(Tok.hasMoreTokens())
prefix = Tok.nextToken();
double secs=tok1;
String temps2 = "";
int roundMin = (int)Math.floor(tok1/60); //4
double fracSec = tok1/60 - roundMin; //.314
int roundSec = (int)Math.floor(fracSec * 60); //18
double tempFrame = fracSec*60 - roundSec; //.84
int frame = (int)Math.floor(tempFrame/0.0133333333);
if(frame>=75)
{
roundSec++;
frame = 0;
}
if(roundMin<=9)
{
lAdd_min = "0";
}
if(roundSec<=9)
{
lAdd_sec = "0";
}
if(frame<=9)
{
lAdd_frame = "0";
}
cueFinal = lAdd_min + roundMin + ":" + lAdd_sec + roundSec + ":" + lAdd_frame + frame;
return cueFinal;
}(1) Where in the world would I start adding code to the Audacity source code to convert label files to cue files? (What header files, C source files, etc). Need some general direction here.
(2) If accepted, which would be better in your opinion - converting .txt to .cue or natively creating a .cue file? .txt to .cue would certainly be easier, in my opinion.
(3) Is anybody else interested in helping me out here? If somebody else likes my code and decides to actually use it, PLEASE give me credit. It'd be nice (=
Thanks!