[linux-audio-user] single WAV + CUE -> multiple FLACs

Tobias Ulbricht up5a at stud.uni-karlsruhe.de
Wed Mar 23 20:09:01 EST 2005


Hi.

Well, you'll see below what I did in the last hour ...(stupid me)
short answer: try flac --cuesheet="test.cue" ...

or try my script, you'll get some #num.wav files out, which you could process by:

bash# for i in *.wav; do flac $i; done

hope somethings help, cheers, tobias.


On Wed, Mar 23, 2005 at 10:34:52PM +0300, Andrew Gaydenko wrote:
> Hi!
> 
> What is the quickest way to convert (single wav file + cue file) 
> to multiple flac files?
> 
> Thanks!
> Andrew

-- 
ThatThatThatThatThatCan'tYearstreamAllcommandSOFTWAREdirectoryREADMEvariouscodePlayerAudioBeautiful










-------------- next part --------------
#!/usr/bin/python
#
# (c) 2005 Tobias Ulbricht
#
# stupid little script
# wanted to abstract a cue file, but ran out of motivation half way through

# it can do: convert a .wav file into several wav files, using a cue sheet
#            and ecasound to split the files.
#
#
# just found that the flac encoder might do the whole stuff with the --cuesheet 
# option - sigh - well a practice in scripting anyway..



import string
import os

class cuefile:
	def __init__(self,filename):
		self.filename = filename
		self.fd = open(filename, "r")
		if (self.fd == 0):
			throw()
		self.tracks = []
		self.offsets = []
		self.offsets_secs = []
		self.audiofilename = self.parse("FILE")[0]
	def parse(self, token):
		list = []
		self.fd.seek(0)
		for line in self.fd.readlines():
			line = string.lstrip(line)
			if string.find(line, token) != -1:
				list.append(string.rstrip(line))
		return list
	def readtracks(self):
		self.tracks = self.parse("TRACK")
	def readoffsets(self):
		self.offsets = self.parse("INDEX")
	def readaudiotracks(self):
		self.readtracks()
		self.readoffsets()
		pos = 0
		for i in self.tracks:
			if string.split(i, " ")[2] == "AUDIO":
				slist = string.split(self.offsets[pos], " ")
				slist = string.split(slist[2], ":")
				secs = string.atoi(slist[0])*60 +string.atoi(slist[1]) + string.atoi(slist[2])/75.0
				self.offsets_secs.append(secs)
				print "audio track no. " + str(pos) + " found. Offset: " + str(secs) + " seconds."
			pos += 1
	def close(self):
		self.fd.close()


mycue = cuefile("test.cue")
mycue.readaudiotracks()
lastoffset = 0
pos = 0
for i in mycue.offsets_secs :
	length = i - lastoffset
        if (length != 0):
		command = 'ecasound -i:"' + string.split(mycue.audiofilename," ")[1] + '" -y ' +str(lastoffset) +' -t ' + str(length) + ' -o ' + str(pos) + '.wav' 
		print "Executing command: \'" + command +"\'"
		os.system( command )
	pos += 1			



mycue.close()


More information about the Linux-audio-user mailing list