Exemple #1
0
def convertToSCV(inputFolder, outputFolder):
    """
        Standard function to convert wave files in folders
        to their respective csv files
    """
    src = files.listDir(inputFolder)
    for f in src:
        waves = wave.loadWave(inputFolder + f)
        frames = wave.getSamples(waves)
        files.write(outputFolder + f[:-4] + ".csv", frames)
Exemple #2
0
def convertToSCV(inputFolder, outputFolder):
    """
        Standard function to convert wave files in folders
        to their respective csv files
    """
    src = files.listDir(inputFolder)
    for f in src:
        waves = wave.loadWave(inputFolder+f)
        frames = wave.getSamples(waves)
        files.write(outputFolder + f[:-4] + ".csv", frames)
Exemple #3
0
def saveFile(path):
    """
        Saves the results in a specific file format.
        For latter comparison
    """
    output = "data.xls"
    f = files.listDir(path)
    for i in f:
        result = stdRun(path + i)
        insertName(output, i, mode='a')
        final = result[0] * 2
        files.writeCSV(output, final, mode='a')
Exemple #4
0
def saveFile(path):
    """
        Saves the results in a specific file format.
        For latter comparison
    """
    output = "data.xls"
    f = files.listDir(path)
    for i in f:
        result = stdRun(path + i)
        insertName(output, i, mode='a')
        final = result[0]*2
        files.writeCSV(output, final, mode='a')
Exemple #5
0
def classify(path, clas):
    """
        Makes a tuple with the file name, its frames and its classification
    """
    f = files.listDir(path)
    res = []
    j = 0
    for i in f:
        frames = files.reader(path + "/" + i)
        res.append([i, frames, clas])
        if j > 2:
            break
        j += 1
        # break#TODO: remove this
    return res
Exemple #6
0
def classify(path, clas):
    """
        Makes a tuple with the file name, its frames and its classification
    """
    f = files.listDir(path)
    res = []
    j = 0
    for i in f:
        frames = files.reader(path + "/" + i)
        res.append([i,frames,clas])
        if j > 2:
            break
        j += 1
        # break#TODO: remove this
    return res
Exemple #7
0
def stdClean(data):
    frames = flt.clean(data)
    frames = stdMovArg(frames)
    frames = flt.halfRate(frames)
    return flt.norm(frames)

def stdRun(path):
    waves = wave.loadWave(path)
    frames = wave.getSamples(waves)
    frames = stdClean(frames)
    return pul.findBeats(frames, 4, 6)

def insertName(path, name, mode='w'):
    f = open(path, mode)
    f.write(name + ',')
    f.close()

if __name__ == '__main__':
    path = sys.argv[1]
    output = "data.xls"
    f = files.listDir(path)
    for i in f:
        print(i)
        result = stdRun(path + i)
        insertName(output, i, mode='a')
        final = result[0]*2
        files.writeCSV(output, final, mode='a')
        for n in range(result[0].size):
            print(result[0][n]*2)
        print("n beats: " + str(result[1].size))