当前位置: 首页>>代码示例>>Python>>正文


Python Main.getBeatMarkers方法代码示例

本文整理汇总了Python中Main.getBeatMarkers方法的典型用法代码示例。如果您正苦于以下问题:Python Main.getBeatMarkers方法的具体用法?Python Main.getBeatMarkers怎么用?Python Main.getBeatMarkers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Main的用法示例。


在下文中一共展示了Main.getBeatMarkers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import Main [as 别名]
# 或者: from Main import getBeatMarkers [as 别名]
def main():
    for filename in os.listdir(os.getcwd() + '/Output'): 
        if(filename[-4:] == '.mp3'): os.remove('Output/' + filename)
    localAudioFiles = []
    for filename in os.listdir(os.getcwd() + '/Input'):
        print filename
        if(filename != '.DS_Store' and filename != 'Thumb.db'):
            localAudioFiles.append(audio.LocalAudioFile('Input/' + filename))
    keys = [localAudioFiles[0].analysis.key['value'], localAudioFiles[1].
                analysis.key['value'], 0,0,0]
    for i,laf in enumerate(localAudioFiles[0:2]):
            if(laf.analysis.mode['value'] == 0): keys[i] = keys[i]+3
            if(keys[i] > 11): keys[i] = keys[i] - 12
    tempos = [localAudioFiles[0].analysis.tempo['value'], localAudioFiles[1].
                  analysis.tempo['value'], 0,0,0]
    localAudioFiles = matchTempoAndKey(localAudioFiles, tempos, keys)
    for i in range(3): localAudioFiles[i+2].encode(str(i)+'.mp3')
    print "tempos after match should equal midTempo: ", [laf.analysis.tempo['value']
                                                             for laf in localAudioFiles]
    equalize_tracks([localAudioFiles[0],localAudioFiles[1],localAudioFiles[2]])
    equalize_tracks([localAudioFiles[3],localAudioFiles[4]])
    print "len(localAudioFiles)/5 after match: ", len(localAudioFiles)/5
    loudnessMarkers = Main.findLoudestRegion([localAudioFiles[0].analysis.segments,
            localAudioFiles[1].analysis.segments],
            [localAudioFiles[0].analysis.tempo['value'],
            localAudioFiles[1].analysis.tempo['value']])
    beatMarkers = Main.getBeatMarkers(loudnessMarkers,
            [localAudioFiles[0].analysis.segments,
            localAudioFiles[1].analysis.segments],[localAudioFiles[0].analysis.beats,
            localAudioFiles[1].analysis.beats])
    mashComponents(localAudioFiles, beatMarkers)  
开发者ID:JordanHawkins,项目名称:Demonstrations,代码行数:33,代码来源:AutoMashUp.py

示例2: main

# 需要导入模块: import Main [as 别名]
# 或者: from Main import getBeatMarkers [as 别名]
def main():
    flushDirectory()
    filenames = getAudioFiles()
    for j in range(len(filenames)/5):
        localAudioFiles = [audio.LocalAudioFile(filenames[5*j], verbose=False),
                           audio.LocalAudioFile(filenames[5*j+1], verbose=False)]
        localAudioFiles.append(audio.AudioData(filenames[5*j+2], sampleRate=44100, 
                                               numChannels=2, verbose=False))
        localAudioFiles.append(audio.AudioData(filenames[5*j+3], sampleRate=44100, 
                                               numChannels=2, verbose=False))
        localAudioFiles.append(audio.AudioData(filenames[5*j+4], sampleRate=44100, 
                                               numChannels=2, verbose=False))
        keys = [localAudioFiles[0].analysis.key['value'], localAudioFiles[1].
                analysis.key['value'], 0,0,0]
        for i,laf in enumerate(localAudioFiles[0:2]):
            if(laf.analysis.mode['value'] == 0): keys[i] = keys[i]+3
            if(keys[i] > 11): keys[i] = keys[i] - 12
        print "keys: ", keys
        tempos = [localAudioFiles[0].analysis.tempo['value'], localAudioFiles[1].
                  analysis.tempo['value'], 0,0,0]
        deleteOldSongs([os.path.basename(laf.filename) for laf in localAudioFiles])
        localAudioFiles = matchTempoAndKey(localAudioFiles, tempos, keys)
        for i in range(3): localAudioFiles[i+2].encode(str(i)+'.mp3')
        print "tempos after match should equal midTempo: ", [laf.analysis.tempo['value']
                                                             for laf in localAudioFiles]
        equalize_tracks([localAudioFiles[0],localAudioFiles[1],localAudioFiles[2]])
        equalize_tracks([localAudioFiles[3],localAudioFiles[4]])
        print "len(localAudioFiles)/5 after match: ", len(localAudioFiles)/5
        loudnessMarkers = Main.findLoudestRegion([localAudioFiles[0].analysis.segments,
            localAudioFiles[1].analysis.segments],
            [localAudioFiles[0].analysis.tempo['value'],
            localAudioFiles[1].analysis.tempo['value']])
        beatMarkers = Main.getBeatMarkers(loudnessMarkers,
            [localAudioFiles[0].analysis.segments,
            localAudioFiles[1].analysis.segments],[localAudioFiles[0].analysis.beats,
            localAudioFiles[1].analysis.beats])
        mashComponents(localAudioFiles, beatMarkers)  
开发者ID:JordanHawkins,项目名称:AutomaticDJ,代码行数:39,代码来源:AutoMashUp.py


注:本文中的Main.getBeatMarkers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。