# standard library
from __future__ import print_function
import logging

# custom libraries
from zignal.audio import Sinetone, Noise, Audio, SquareWave

if __name__ == '__main__':
    logging.basicConfig(format='%(levelname)-7s: %(module)s.%(funcName)-15s %(message)s',
                        level='DEBUG')
    
    fs  = 48000
    dur = 1.5
    
    x1 = Sinetone(f0=997, fs=fs, duration=dur, gaindb=0)
    x2 = Noise(fs=fs, duration=dur, gaindb=-6)
    x3 = SquareWave(f0=3000, fs=fs, duration=dur, gaindb=-20)
    x4 = Audio(fs=fs)
    x4.append(x1, x2, x3)
    
    print(x1)
    print(x1.peak())
    print(x1.rms())
    print(x1.crest_factor())
    
    print(x2)
    print(x2.peak())
    print(x2.rms())
    print(x2.crest_factor())
    
示例#2
0
'''
Created on 15 Feb 2015

@author: Ronny Andersson ([email protected])
@copyright: (c) 2015 Ronny Andersson
@license: MIT
'''

# standard library
from __future__ import print_function
import logging

# custom libraries
from zignal.audio import Sinetone

if __name__ == '__main__':
    logging.basicConfig(format='%(levelname)-7s: %(module)s.%(funcName)-15s %(message)s',
                        level='DEBUG')
    
    fs  = 1000
    f0  = 10
    dur = 0.1
    
    x = Sinetone(f0=f0, fs=fs, duration=dur, gaindb=0)
    print(x)
    x.plot(linestyle='--', marker='x', color='r', label='sine at %i Hz' %f0)
    
    x.set_sample_rate(500)
    print(x)
    x.plot(linestyle='-.', color='k', label='sine at %i Hz' %f0)
示例#3
0
'''
Created on 15 Feb 2015

@author: Ronny Andersson ([email protected])
@copyright: (c) 2015 Ronny Andersson
@license: MIT
'''

# standard library
from __future__ import print_function
import logging

# custom libraries
from zignal.audio import Sinetone, Noise

if __name__ == '__main__':
    logging.basicConfig(format='%(levelname)-7s: %(module)s.%(funcName)-15s %(message)s',
                        level='DEBUG')
    
    fs  = 96000
    f0  = 997
    dur = 2.5
    
    x   = Sinetone(f0=f0, fs=fs, duration=dur, gaindb=0)
    n   = Noise(channels=1, fs=fs, duration=dur, gaindb=-50)
    print(x)
    print(n)
    
    x.samples = x.samples+n.samples
    
    x.plot_fft(window='hamming')