Changeset 066433d for interfaces/python


Ignore:
Timestamp:
Jan 9, 2010, 3:51:20 PM (15 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:
d453a4a
Parents:
8212692 (diff), 37eb9ce (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with mono

Location:
interfaces/python
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • interfaces/python/aubio/__init__.py

    r8212692 r066433d  
    44class fvec(numpy.ndarray):
    55
    6     def __init__(self, length = 1024, **kwargs):
    7         super(numpy.ndarray, self).__init__(**kwargs)
    8 
    96    def __new__(self, length = 1024, **kwargs):
    10         self = numpy.zeros(length, dtype='float32', **kwargs)
    11         return self
     7        if type(length) == type([]):
     8            return numpy.array(length, dtype='float32', **kwargs)
     9        return numpy.zeros(length, dtype='float32', **kwargs)
  • interfaces/python/aubioinput.py

    r8212692 r066433d  
    1010    import numpy
    1111    samples = numpy.frombuffer(buffer.data, dtype=numpy.float32)
    12     samples.resize([len(samples)/chan, chan])
    13     return samples.T
     12    if chan == 1:
     13        return samples.T
     14    else:
     15        samples.resize([len(samples)/chan, chan])
     16        return samples.T
    1417
    1518class AubioSink(gst.BaseSink):
     
    5356            if self.process:
    5457                self.process(v, self.pos)
    55             self.pos += 1   
     58            self.pos += 1
     59        remaining = self.adapter.available()
     60        if remaining < blocksize and remaining > 0:
     61            block = self.adapter.take_buffer(remaining)
     62            v = gst_buffer_to_numpy_array(block, chan)
     63            if self.process:
     64                self.process(v, self.pos)
     65            self.pos += 1
    5666        return gst.FLOW_OK
    5767
  • interfaces/python/test_fvec.py

    r8212692 r066433d  
    1313        #del a
    1414        assert_equal(array(a), 0.)
     15
     16    def test_vector_create_with_list(self):
     17        a = fvec([0,1,2,3])
     18        assert_equal (range(4), a)
    1519
    1620    def test_vector_assign_element(self):
     
    5357        from math import sqrt
    5458        assert_almost_equal (alpha_norm(a, 2), sqrt(2)/2.)
     59
     60    def test_alpha_norm_of_none(self):
     61        self.assertRaises (ValueError, alpha_norm, None, 1)
    5562
    5663    def test_alpha_norm_of_array_of_float32(self):
Note: See TracChangeset for help on using the changeset viewer.