예제 #1
0
    wav = Sndfile(newfn, 'w', fmt, cols.shape[1], samplerate)
    a = arange(samplerate) / samplerate + time[0]
    for i in xrange(int((time[-1] - time[0]))):
        y = array([g(a + i) for g in f]).T
        wav.write_frames(y)
        print '%0.2f%%     \r' % (i / (time[-1] - time[0]) * 100),
        sys.stdout.flush()
    print '100%     '


def export_audio_all_minibees(minibees, prefix, ext):
    samplerate = 44100.0
    amplitude = 520.0

    for n in minibees:
        data = minibees[n]
        offsets = find_offsets(data)
        d = split_data_on_offsets(data, offsets)

        newfn = '%s,%d.%s' % (prefix, n, ext)

        [
            export_audio_vidId(newfn, samplerate, a[0, 3], a[:, 4] / 30.0,
                               a[:, 5:8] / amplitude) for a in d
        ]


if __name__ == "__main__":
    minibees, fields = read_minibees()
    export_audio_all_minibees(minibees, 'minibee', 'aiff')
예제 #2
0
# def load_gestures():
#     from bz2 import BZ2File
#     gestures = []
#     #for g in BZ2File('../../dotminibee/software/gestures.txt.bz2'):
#     for g in BZ2File('gestures.txt.bz2'):
#         d = [float(x) for x in g.split('[')[1].split(']')[0].split(',')]
#         gestures.append(d)
#     return array(gestures)

# data, sr = mag(load_gestures()), 200.0
# fulldata = data
# data = sig.lfilter(*sig.butter(2, 0.1, 'low'),x=fulldata)[::10]
# sr = 200/10

minibees, fields = read_minibees()

def unwrap_time(time, timediff):
    brks = [n for n,d in enumerate((time[1:]-time[:-1])) if d < -timediff]
    idx = arange(time.size)
    return sum([time] + [(idx > b)*time[b] for b in brks], axis=0)

time_range = (0,100000000000)
all_interp = {}
for m in minibees.keys():
    time = unwrap_time(minibees[m][:,4]/30.0, 500)
    time_range = (max(time_range[0], time[0]),
                  min(time_range[1], time[-1]))

for m in minibees.keys():
    time = unwrap_time(minibees[m][:,4]/30.0, 500)