示例#1
0
def main():
    # This setups up a parser for the various input options
    usage = "usage: %s [options] <one_single_mp3>" % sys.argv[0]
    parser = OptionParser(usage=usage)
    parser.add_option("-o",
                      "--offset",
                      default=0,
                      help="offset where to start counting")
    parser.add_option("-l", "--low", default=100, help="low tempo")
    parser.add_option("-H", "--high", default=192, help="high tempo")
    parser.add_option("-r",
                      "--rate",
                      default=0,
                      help="acceleration rate (try 30)")
    parser.add_option("-R",
                      "--rubato",
                      default=0,
                      help="rubato on second beat (try 0.2)")
    parser.add_option("-t",
                      "--tempo",
                      default=0,
                      help="target tempo (try 160)")
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      help="show results on screen")

    # If we don't have enough options, exit!
    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.print_help()
        return -1

    verbose = options.verbose

    # This gets the analysis for this file
    track = LocalAudioFile(args[0], verbose=verbose)

    if verbose:
        print "Waltzifying..."

    # This is where the work takes place
    actions = do_work(track, options)

    if verbose:
        display_actions(actions)

    # This makes the new name for the output file
    name = os.path.splitext(os.path.basename(args[0]))
    name = str(name[0] + '_waltz_%d' % int(options.offset) + '.mp3')

    if verbose:
        print "Rendering... %s" % name

    # This renders the audio out to the output file
    render(actions, name, verbose=verbose)
    if verbose:
        print "Success!"
    return 1
示例#2
0
文件: earworm.py 项目: also/earworm
def main():
    usage = "usage: %s [options] <one_single_mp3>" % sys.argv[0]
    parser = OptionParser(usage=usage)
    parser.add_option("-d", "--duration", default=DEF_DUR, help="target duration (argument in seconds) default=600")
    parser.add_option("-m", "--minimum", default=MIN_JUMP, help="minimal loop size (in beats) default=8")
    parser.add_option("-i", "--infinite", action="store_true", help="generate an infinite loop (outputs a wav file)")
    parser.add_option("-l", "--length", action="store_true", help="length must be accurate")
    parser.add_option("-k", "--pickle", action="store_true", help="output graph as a pickle object")
    parser.add_option("-g", "--graph", action="store_true", help="output graph as a gml text file")
    parser.add_option("-p", "--plot", action="store_true", help="output graph as png image")
    parser.add_option("-f", "--force", action="store_true", help="force (re)computing the graph")
    parser.add_option("-S", "--shortest", action="store_true", help="output the shortest loop")
    parser.add_option("-L", "--longest", action="store_true", help="output the longest loop")
    parser.add_option("-v", "--verbose", action="store_true", help="show results on screen")

    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.print_help()
        return -1

    track = None
    if len(args) == 2:
        track = find_track(args[0], args[1])
        if not track:
            print "Couldn't find %s by %s" % (args[0], args[1])
            return 1
    else:
        mp3 = args[0]

        if os.path.exists(mp3 + '.json'):
            track = AnalyzedAudioFile(mp3)
        else:
            track = LocalAudioFile(mp3)

    # this is where the work takes place
    actions = do_work(track, options)

    if bool(options.verbose) == True:
        display_actions(actions)

    print "Output Duration = %.3f sec" % sum(act.duration for act in actions)

    # Send to renderer
    name = os.path.splitext(os.path.basename(args[0]))

    # Output wav for loops in order to remain sample accurate
    if bool(options.infinite) == True:
        name = name[0]+'_'+str(int(options.duration))+'_loop.wav'
    elif bool(options.shortest) == True:
        name = name[0]+'_'+str(int(sum(act.duration for act in actions)))+'_shortest.wav'
    elif bool(options.longest) == True:
        name = name[0]+'_'+str(int(sum(act.duration for act in actions)))+'_longest.wav'
    else:
        name = name[0]+'_'+str(int(options.duration))+'.mp3'

    print "Rendering..."
    render(actions, name)
    return 1
示例#3
0
def main():
    usage = "usage: %s [options] <one_single_mp3>" % sys.argv[0]

    parser = OptionParser(usage=usage)
    parser.add_option("-p", "--pattern", default="1", help="tempo pattern, default 1 (every beat at same tempo)\
    	Each beat will be sped up by a factor of the corresponding digit in the pattern. 0 will drop a beat\
    	1122 will take each four beats, and squish the last two (making a waltz)\
    	12 will squish every alternating beat (long swing, depending on the song)\
        1110 will drop every 4th beat\
    	Much crazier is possible. Also note that the beat detection is sometimes off/ not aligned with bars.\
    	Use -d with \"1111\" to find out what four beats will be grouped at a time.\"\
    	")
    parser.add_option("-s", "--slowdown", default=1, help="General factor of slowdown")
    parser.add_option("-f", "--format", default="mp3", help="Output format (e.g. mp3, wav)")
    parser.add_option("-d", "--debug", action="store_true", help="General factor of slowdown")
    parser.add_option("-v", "--verbose", action="store_true", help="show results on screen")
    
    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.print_help()
        return -1
    
    track = None
    mp3 = args[0]
    

    track = LocalAudioFile(mp3)
    
    # this is where the work takes place
    actions = do_work(track, options)
    
    if bool(options.verbose) == True:
        display_actions(actions)
    
    # Send to renderer
    name = os.path.splitext(os.path.basename(args[0]))
    beat_signature = options.pattern;
    if (float(options.slowdown) != 1):
    	beat_signature = beat_signature + "_" + options.slowdown
    name = name[0]+'_'+beat_signature+'.'+options.format
    name = name.replace(' ','')
    
    print "Rendering..."
    render(actions, name)
    return 1
示例#4
0
def main():
    # This setups up a parser for the various input options
    usage = "usage: %s [options] <one_single_mp3>" % sys.argv[0]
    parser = OptionParser(usage=usage)
    parser.add_option("-o", "--offset", default=0, help="offset where to start counting")
    parser.add_option("-l", "--low", default=100, help="low tempo")
    parser.add_option("-H", "--high", default=192, help="high tempo")
    parser.add_option("-r", "--rate", default=0, help="acceleration rate (try 30)")
    parser.add_option("-R", "--rubato", default=0, help="rubato on second beat (try 0.2)")
    parser.add_option("-t", "--tempo", default=0, help="target tempo (try 160)")
    parser.add_option("-v", "--verbose", action="store_true", help="show results on screen")
    
    # If we don't have enough options, exit!
    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.print_help()
        return -1
    
    verbose = options.verbose

    # This gets the analysis for this file
    track = LocalAudioFile(args[0], verbose=verbose)
    
    if verbose:
        print "Waltzifying..."

    # This is where the work takes place
    actions = do_work(track, options)

    if verbose:
        display_actions(actions)
    
    # This makes the new name for the output file
    name = os.path.splitext(os.path.basename(args[0]))
    name = str(name[0] + '_waltz_%d' % int(options.offset) +'.mp3')
    
    if verbose:
        print "Rendering... %s" % name

    # This renders the audio out to the output file
    render(actions, name, verbose=verbose)
    if verbose:
        print "Success!"
    return 1
示例#5
0
文件: waltzify.py 项目: phlegma/remix
def main():
    usage = "usage: %s [options] <one_single_mp3>" % sys.argv[0]
    parser = OptionParser(usage=usage)
    parser.add_option("-o", "--offset", default=0, help="offset where to start counting")
    parser.add_option("-l", "--low", default=100, help="low tempo")
    parser.add_option("-H", "--high", default=192, help="high tempo")
    parser.add_option("-r", "--rate", default=0, help="acceleration rate (try 30)")
    parser.add_option("-R", "--rubato", default=0, help="rubato on second beat (try 0.2)")
    parser.add_option("-t", "--tempo", default=0, help="target tempo (try 160)")
    parser.add_option("-v", "--verbose", action="store_true", help="show results on screen")

    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.print_help()
        return -1

    verbose = options.verbose

    # get Echo Nest analysis for this file
    track = LocalAudioFile(args[0], verbose=verbose)

    if verbose:
        print "Waltzifying..."

    # this is where the work takes place
    actions = do_work(track, options)

    if verbose:
        display_actions(actions)

    # new name
    name = os.path.splitext(os.path.basename(args[0]))
    name = str(name[0] + "_waltz_%d" % int(options.offset) + ".mp3")

    if verbose:
        print "Rendering... %s" % name

    # send to renderer
    render(actions, name, verbose=verbose)

    if verbose:
        print "Success!"

    return 1
示例#6
0
def main():
	usage = "usage: %s [options] <one_single_mp3>" % sys.argv[0]
	parser = OptionParser(usage=usage)
	parser.add_option("-w", "--waltz", default=2, help="where to put the extra beat, value of 1, 2, or 3, default=2")
	parser.add_option("-v", "--verbose", action="store_true", help="show results on screen")
	
	(options, args) = parser.parse_args()
	if len(args) < 1:
		parser.print_help()
		return -1
	
	verbose = options.verbose
	track = None
	
	track = LocalAudioFile(args[0], verbose=verbose)
	if verbose:
		print "Computing waltz . . ."
		
	# this is where the work takes place
	actions = do_work(track, options)

	if verbose:
		display_actions(actions)

	if verbose:
		print "Song is in %s/4 time" % int(track.analysis.time_signature['value'])
	
	# Send to renderer
	name = os.path.splitext(os.path.basename(args[0]))

	name = name[0] + '_waltz_b' + str(int(options.waltz)) + '.mp3'
	name = name.replace(' ','') 
	name = os.path.join(os.getcwd(), name) # TODO: use sys.path[0] instead of getcwd()?

	if verbose:
		print "Rendering... %s" % name
        
	render(actions, name, verbose=verbose)
	if verbose:
		print "Success!"
	return 1
示例#7
0
def main():
    # This setups up a parser for the various options
    usage = "usage: %s [options] <one_single_mp3>" % sys.argv[0]
    parser = OptionParser(usage=usage)
    parser.add_option("-s", "--swing", default=0.33, help="swing factor default=0.33")
    parser.add_option("-v", "--verbose", action="store_true", help="show results on screen")
    
    # If we don't have enough options, exit!
    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.print_help()
        return -1
    
    # Set up the track and verbose-ness
    verbose = options.verbose
    track = None
    track = LocalAudioFile(args[0], verbose=verbose)
    if verbose:
        print "Computing swing . . ."

    # This is where the work takes place
    actions = do_work(track, options)
    
    if verbose:
        display_actions(actions)
    
    # This renders the audio out to the new file
    name = os.path.splitext(os.path.basename(args[0]))
    sign = ('-','+')[float(options.swing) >= 0]
    name = name[0] + '_swing' + sign + str(int(abs(float(options.swing))*100)) +'.mp3'
    name = name.replace(' ','') 
    name = os.path.join(os.getcwd(), name) # TODO: use sys.path[0] instead of getcwd()?
    
    if verbose:
        print "Rendering... %s" % name
    render(actions, name, verbose=verbose)
    if verbose:
        print "Success!"
    return 1
示例#8
0
def main():
    usage = "usage: %s [options] <one_single_mp3>" % sys.argv[0]
    parser = OptionParser(usage=usage)
    parser.add_option("-d",
                      "--duration",
                      default=DEF_DUR,
                      help="target duration (argument in seconds) default=600")
    parser.add_option("-m",
                      "--minimum",
                      default=MIN_JUMP,
                      help="minimal loop size (in beats) default=8")
    parser.add_option("-i",
                      "--infinite",
                      action="store_true",
                      help="generate an infinite loop (outputs a wav file)")
    parser.add_option("-l",
                      "--length",
                      action="store_true",
                      help="length must be accurate")
    parser.add_option("-k",
                      "--pickle",
                      action="store_true",
                      help="output graph as a pickle object")
    parser.add_option("-g",
                      "--graph",
                      action="store_true",
                      help="output graph as a gml text file")
    parser.add_option("-p",
                      "--plot",
                      action="store_true",
                      help="output graph as png image")
    parser.add_option("-f",
                      "--force",
                      action="store_true",
                      help="force (re)computing the graph")
    parser.add_option("-S",
                      "--shortest",
                      action="store_true",
                      help="output the shortest loop")
    parser.add_option("-L",
                      "--longest",
                      action="store_true",
                      help="output the longest loop")
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      help="show results on screen")

    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.print_help()
        return -1

    verbose = options.verbose
    track = LocalAudioFile(args[0], verbose=verbose)

    # this is where the work takes place
    actions = do_work(track, options)

    if verbose:
        display_actions(actions)
        print "Output Duration = %.3f sec" % sum(act.duration
                                                 for act in actions)

    # Send to renderer
    name = os.path.splitext(os.path.basename(args[0]))

    # Output wav for loops in order to remain sample accurate
    if bool(options.infinite) == True:
        name = name[0] + '_' + str(int(options.duration)) + '_loop.wav'
    elif bool(options.shortest) == True:
        name = name[0] + '_' + str(int(sum(
            act.duration for act in actions))) + '_shortest.wav'
    elif bool(options.longest) == True:
        name = name[0] + '_' + str(int(sum(
            act.duration for act in actions))) + '_longest.wav'
    else:
        name = name[0] + '_' + str(int(options.duration)) + '.mp3'

    if options.verbose:
        print "Rendering..."
    render(actions, name, verbose=verbose)
    return 1