Open Quasimondo opened 8 years ago
I could fix it by changing the mix() function in audio.py. Not sure if this is very effective, but it works for me:
def mix(dataA, dataB, mix=0.5):
"""
Mixes two `AudioData` objects. Assumes they have the same sample rate
and number of channels.
Mix takes a float 0-1 and determines the relative mix of two audios.
i.e., mix=0.9 yields greater presence of dataA in the final mix.
"""
if dataA.endindex > dataB.endindex:
newdata = AudioData(ndarray=dataA.data, sampleRate=dataA.sampleRate, numChannels=dataA.numChannels, defer=False)
tempdataA = newdata.data.astype(numpy.float64)
tempdataA *= float(mix)
tempdataB = dataB.data.astype(numpy.float64)[:]
tempdataA[:dataB.endindex] += tempdataB * (1 - float(mix))
else:
newdata = AudioData(ndarray=dataB.data, sampleRate=dataB.sampleRate, numChannels=dataB.numChannels, defer=False)
tempdataA = newdata.data.astype(numpy.float64)
tempdataA *= 1 - float(mix)
tempdataB = dataA.data.astype(numpy.float64)[:]
tempdataA[:dataA.endindex] += tempdataB * float(mix)
newdata.data = tempdataA.astype(numpy.int16,casting='unsafe')
return newdata
I am getting a casting error when trying to run the afromb example:
which looks very similar to the closed issue #13
I'm using an Anaconda Python 2.7 install which might contribute to the problem, though other examples work fine.