Changeset 6d8db80


Ignore:
Timestamp:
Jan 17, 2016, 3:14:44 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
94b16497
Parents:
0e39e88
Message:

python/demos/demo_pysoundcard_*: update to pysoundcard 0.5.2 (closes #42)

Location:
python/demos
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/demos/demo_pysoundcard_play.py

    r0e39e88 r6d8db80  
    1111    samplerate = f.samplerate
    1212
    13     s = Stream(sample_rate = samplerate, block_length = hop_size)
     13    s = Stream(samplerate = samplerate, blocksize = hop_size)
    1414    s.start()
    1515    read = 0
  • python/demos/demo_pysoundcard_record.py

    r0e39e88 r6d8db80  
    99    hop_size = 256
    1010    duration = 5 # in seconds
    11     s = Stream(block_length = hop_size)
    12     g = sink(sink_path, samplerate = s.sample_rate)
     11    s = Stream(blocksize = hop_size, channels = 1)
     12    g = sink(sink_path, samplerate = int(s.samplerate))
     13    print s.channels
    1314
    1415    s.start()
    1516    total_frames = 0
    16     while total_frames < duration * s.sample_rate:
    17         vec = s.read(hop_size)
    18         # mix down to mono
    19         mono_vec = vec.sum(-1) / float(s.input_channels)
    20         g(mono_vec, hop_size)
    21         total_frames += hop_size
     17    try:
     18        while total_frames < duration * s.samplerate:
     19            vec = s.read(hop_size)
     20            # mix down to mono
     21            mono_vec = vec.sum(-1) / float(s.channels[0])
     22            g(mono_vec, hop_size)
     23            total_frames += hop_size
     24    except KeyboardInterrupt, e:
     25        print "stopped after", "%.2f seconds" % (total_frames / s.samplerate)
     26        pass
    2227    s.stop()
    2328
Note: See TracChangeset for help on using the changeset viewer.