def __init__(self, format, parent=None):

        QIODevice.__init__(self, parent)
        self.data = QByteArray()

        # Preserve phase across calls
        self.phase = 0
        self.freq = 440

        self.convert_16_bit = float(2**15)

        coefs = self.getCoef()

        self.white_osc = noise.WhiteNoise()

        self.white_buffer = self.white_osc.genBuffer(
            Meep.SAMPLES_PER_READ)  # gen white buffer
        self.filter = sf.FilterChain(coefs)

        # Check we can deal with the supplied
        # sample format. We're supposed to be
        # able to deal with any requested
        # sample format. But this is a
        # _minimal_ example, right?
        if format.isValid() and \
           format.sampleSize() == 16 and \
           format.byteOrder() == \
                QAudioFormat.LittleEndian and \
           format.sampleType() == \
                QAudioFormat.SignedInt and \
           format.channelCount() == 1 :
            print("Meep: Format compatible. Good.")
            self.format = format
示例#2
0
 def __init__(self, format, parent=None):
     QIODevice.__init__(self, parent)
     self.data = QByteArray()
     self.format = format
     self.voiceList = []
     self.pulseP = 0.3
     self.q = 100
     self.transpose = 36
示例#3
0
 def __init__(self,format,parent=None):
     self.format=format
     QIODevice.__init__(self,parent)
     self.data=QByteArray()
     self.state=0
     self.vel=0
     self.vol=0
     self.q=0
     self.d=0
示例#4
0
    def __init__(self, dev: QIODevice, msg: str = None) -> None:
        if msg is None:
            msg = dev.errorString()

        super().__init__(msg)

        self.qt_errno = None  # type: typing.Optional[QFileDevice.FileError]
        try:
            self.qt_errno = dev.error()
        except AttributeError:
            pass
示例#5
0
文件: Chunks.py 项目: Andres6936/Hex
 def write(self,
           device: QIODevice,
           position: int = 0,
           count: int = -1) -> bool:
     if count == -1:
         count = self.size
     status = device.open(QIODevice.WriteOnly)
     if status:
         for idx in range(position, count, BUFFER_SIZE):
             array = self.data(idx, BUFFER_SIZE)
             device.write(array)
         device.close()
     return status
示例#6
0
    def __init__(self, dev: QIODevice, msg: str = None) -> None:
        if msg is None:
            msg = dev.errorString()

        self.qt_errno = None  # type: typing.Optional[QFileDevice.FileError]
        if isinstance(dev, QFileDevice):
            msg = self._init_filedev(dev, msg)

        super().__init__(msg)
示例#7
0
    def __init__(self, format, parent = None):
        QIODevice.__init__(self, parent)
        self.data = QByteArray()

        # find bandwith for one hertz
        self.bdw = 2*np.pi/SAMPLE_RATE

        # start off with no note playing (toggled when we detect midi messages)
        self.note_on = 0

        # add freq offset so we can tune keys
        self.octave = 0


        # create Filter
        b, a = signal.iirdesign([0.2,0.21], [0.1,0.3], 3, 80, False, 'butter')
        self.filter = IIR(a,b)

        # create ADSR env. generator
        self.env = ADSR()
        self.env.setAttackRate(.1 * SAMPLE_RATE)
        self.env.setDecayRate(.3 * SAMPLE_RATE)
        self.env.setReleaseRate(5 * SAMPLE_RATE)
        self.env.setSustainLevel(.8)

        print("\n~~~~ GENERATOR ~~~~")

        # Check we can deal with the supplied
        # sample format. We're supposed to be
        # able to deal with any requested
        # sample format. But this is a
        # _minimal_ example, right?
        if format.isValid() and \
           format.sampleSize() == 16 and \
           format.byteOrder() == \
                QAudioFormat.LittleEndian and \
           format.sampleType() == \
                QAudioFormat.SignedInt and \
           format.channelCount() == 1 :
               print(
                 "Sample format compatible."
               )
               self.format = format
    def __init__(self, format, parent=None):

        QIODevice.__init__(self, parent)
        self.data = QByteArray()

        # Preserve phase across calls
        self.phase = 0

        # Check we can deal with the supplied
        # sample format. We're supposed to be
        # able to deal with any requested
        # sample format. But this is a
        # _minimal_ example, right?
        if format.isValid() and \
           format.sampleSize() == 16 and \
           format.byteOrder() == \
                QAudioFormat.LittleEndian and \
           format.sampleType() == \
                QAudioFormat.SignedInt and \
           format.channelCount() == 1 :
            print("Meep: Format compatible. Good.")
            self.format = format
示例#9
0
    def __init__(self, format, activeGen, parent=None):

        QIODevice.__init__(self, parent)
        self.data = QByteArray()

        # hold a reference to the active generator instance
        self.generator = activeGen

        self.convert_16_bit = float(2**15)

        # Check we can deal with the supplied
        # sample format. We're supposed to be
        # able to deal with any requested
        # sample format. But this is a
        # _minimal_ example
        if format.isValid() and \
           format.sampleSize() == 16 and \
           format.byteOrder() == \
                QAudioFormat.LittleEndian and \
           format.sampleType() == \
                QAudioFormat.SignedInt and \
           format.channelCount() == 1 :
            print("Meep: Format compatible. Good.")
            self.format = format