Cue import/export

Audio software developers forum.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
AndrewTheArt
Posts: 8
Joined: Sat Sep 08, 2007 5:00 pm
Operating System: Please select

Cue import/export

Post by AndrewTheArt » Sat Sep 08, 2007 5:53 pm

Hey all -

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;	
	}
I was wondering three things.

(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!
Last edited by AndrewTheArt on Wed Nov 13, 2013 3:26 am, edited 1 time in total.

tekknokrat
Posts: 2
Joined: Mon Jun 23, 2008 5:36 pm
Operating System: Please select

Re: Cue import/export

Post by tekknokrat » Mon Jun 23, 2008 5:49 pm

Hi AndrewTheArt,

I like this contribution for audacity as it is exactly what I need for creating cue files for my mix collection.
Unfortunately the downloadlinks didn't work anymore.
Is it possible to release this neat program at some other place or can you send it to me per pm.

Best Regards,
tekknokrat

steve
Site Admin
Posts: 47595
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Cue import/export

Post by steve » Mon Jun 23, 2008 11:31 pm

Hi AndrewTheArt,
Your Script seems to be attracting some attention at the moment, but unfortunately does not seem to be available.
If you would like somewhere to upload it, PM me and I'll sort a bit of web space out for you.

Re. integrating with Audacity - I've been looking into Nyquist plug-ins recently and I think it could be done quite easily with nyquist. Unfortunately there does not seem to be any way to read label tracks into nyquist plug-ins, but this leaves two other options open: (1) the rather ugly workaround of exporting the label track as a text file, then reading it into nyquist and finally saving as a cue file, or (2) creating the cue file directly.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Pipps
Posts: 4
Joined: Mon Jan 05, 2009 12:33 am
Operating System: Please select

Re: Cue import/export

Post by Pipps » Mon Jan 05, 2009 12:36 am

Hello

I would really like to use this script to master a number of CD recordings. I can't seem to find the label2cue file on Andrew's website or anywhere.

Does anyone have a copy of the label2cue.zip package that they might be willing to make available or send?

Any assistance would be much appreciated!

Thank you.

Pipps

steve
Site Admin
Posts: 47595
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Cue import/export

Post by steve » Mon Jan 05, 2009 5:13 pm

See attachment
Attachments
Label2CueConvertor.zip
(22.03 KiB) Downloaded 551 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Pipps
Posts: 4
Joined: Mon Jan 05, 2009 12:33 am
Operating System: Please select

Re: Cue import/export

Post by Pipps » Mon Jan 05, 2009 7:58 pm

You are a hero! :D

Thank you! :)

steve
Site Admin
Posts: 47595
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Cue import/export

Post by steve » Mon Jan 05, 2009 8:21 pm

Pipps wrote:You are a hero! :D
Not me - it's AndrewTheArt that deserves the thanks ;)
Let us know how you get on with it (I don't use cue sheets, so I've not tried it myself).
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Pipps
Posts: 4
Joined: Mon Jan 05, 2009 12:33 am
Operating System: Please select

Re: Cue import/export

Post by Pipps » Tue Jan 06, 2009 8:46 pm

You're right - And I wish I could thank Andrew, if only his website was working! :geek:

You don't use cue sheets? :o

They are wonderfully convenient. I hope you get the chance to enjoy them one day! :D

steve
Site Admin
Posts: 47595
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Cue import/export

Post by steve » Tue Jan 06, 2009 10:44 pm

Pipps wrote:You don't use cue sheets? :o
No, I just use K3B or Nero and let the computer do all the work ;)

Some time ago I spoke with Andrew about the possibility of collaborating on a Nyquist plug-in for exporting cue sheets from Audacity. At the time, he was interested, but rather too busy. Right now, I'm rather busy too, but if you find yourself still loitering round the forum in a month or two, perhaps I could pick your brains and we could see if we can come up with something. (I'm gradually getting to know how to do things in Nyquist, but I know nothing about cue sheets, so that'd be your part of the job :)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Pipps
Posts: 4
Joined: Mon Jan 05, 2009 12:33 am
Operating System: Please select

Re: Cue import/export

Post by Pipps » Wed Jan 07, 2009 10:25 am

I would be delighted to assist!

Allow me to send you a PM with my contact details.

It will be great to collaborate with you when you have some free time to undertake this project. It would make Audacity even more superior to other audio editing suites!

Post Reply