コード例 #1
0
ファイル: generatetrm.py プロジェクト: rodbegbie/MetaRipper
def getSignature(filename, playWhileReading=None):
    (path, ext) = os.path.splitext(filename)
    if ext.lower() == '.ogg':
        ff = ogg.vorbis.VorbisFile(filename)
    elif ext.lower() == '.mp3':
        ff = MadWrapper(filename)
    elif ext.lower() == '.wav':
        ff = WavWrapper(filename)
    else:
        raise SystemError, "Unsupported audio file."

    if playWhileReading:
        device = 'esd'
        id = ao.driver_id(device)
        aodev = ao.AudioDevice(id)

    info = ff.info()
    trm = musicbrainz.trm()
    trm.SetPCMDataInfo(info.rate, info.channels, 16)
    while 1:
        (buff, bytes, bit) = ff.read()
        if bytes == 0:
            break
        if trm.GenerateSignature(buff):
            break
        if playWhileReading:
            aodev.play(buff, bytes)

    sig = trm.FinalizeSignature()

    return sig
コード例 #2
0
def getSignature(filename, playWhileReading = None): 
    (path, ext) = os.path.splitext(filename)
    if ext.lower() == '.ogg':
        ff = ogg.vorbis.VorbisFile(filename)
    elif ext.lower() == '.mp3':
        ff = MadWrapper(filename)
    elif ext.lower() == '.wav':
        ff = WavWrapper(filename)
    else:
        raise SystemError, "Unsupported audio file."

    if playWhileReading:
        device = 'esd'
        id = ao.driver_id(device)
        aodev = ao.AudioDevice(id)

    info = ff.info()
    trm = musicbrainz.trm()
    trm.SetPCMDataInfo(info.rate, info.channels, 16)
    while 1:
        (buff, bytes, bit) = ff.read()
        if bytes == 0:
            break
        if trm.GenerateSignature(buff):
            break
        if playWhileReading:
            aodev.play(buff, bytes)

    sig = trm.FinalizeSignature()

    return sig
コード例 #3
0
def get_trm(ff):
    info = ff.info()
    trm = musicbrainz.trm()
    trm.SetPCMDataInfo(info.rate, info.channels, 16)
    while 1:
        (buff, bytes, bit) = ff.read()
        if bytes == 0:
            break
        if trm.GenerateSignature(buff):
            break
        
    return trm.FinalizeSignature()
コード例 #4
0
ファイル: cd2trm.py プロジェクト: myers/python-musicbrainz
def getSignature(filename, songLength=None): 
    (path, ext) = os.path.splitext(filename)
    if ext.lower() == '.wav':
        ff = WavWrapper(filename)
    else:
        raise SystemError, "Unsupported audio file."

    info = ff.info()
    trm = musicbrainz.trm()
    trm.SetPCMDataInfo(info.rate, info.channels, 16)
    if songLength:
        trm.SetSongLength(songLength)
    while 1:
        (buff, bytes, bit) = ff.read()
        if bytes == 0:
            break
        if trm.GenerateSignature(buff):
            break
    sig = trm.FinalizeSignature()

    return sig
コード例 #5
0
ファイル: cd2trm.py プロジェクト: rodbegbie/MetaRipper
def getSignature(filename, songLength=None):
    (path, ext) = os.path.splitext(filename)
    if ext.lower() == '.wav':
        ff = WavWrapper(filename)
    else:
        raise SystemError, "Unsupported audio file."

    info = ff.info()
    trm = musicbrainz.trm()
    trm.SetPCMDataInfo(info.rate, info.channels, 16)
    if songLength:
        trm.SetSongLength(songLength)
    while 1:
        (buff, bytes, bit) = ff.read()
        if bytes == 0:
            break
        if trm.GenerateSignature(buff):
            break
    sig = trm.FinalizeSignature()

    return sig