コード例 #1
0
ファイル: ex_fourier.py プロジェクト: adrian-stepien/zignal
@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 Audio, FourierSeries

if __name__ == '__main__':
    logging.basicConfig(format='%(levelname)-7s: %(module)s.%(funcName)-15s %(message)s',
                        level='DEBUG')
    
    dur = 0.1
    f0  = 20
    
    k   = Audio()
    x0  = FourierSeries(f0=f0, duration=dur, harmonics=0,  gaindb=-15)  # fundamental + 0 harmonics
    x1  = FourierSeries(f0=f0, duration=dur, harmonics=1,  gaindb=-15)  # fundamental + 1 harmonics
    x2  = FourierSeries(f0=f0, duration=dur, harmonics=2,  gaindb=-9)   # fundamental + 2 harmonics
    x3  = FourierSeries(f0=f0, duration=dur, harmonics=3,  gaindb=-9)   # ...
    x4  = FourierSeries(f0=f0, duration=dur, harmonics=4,  gaindb=-3)
    x5  = FourierSeries(f0=f0, duration=dur, harmonics=5,  gaindb=-3)
    x60 = FourierSeries(f0=f0, duration=dur, harmonics=60, gaindb=0)    # fundamental + 60 harmonics
    
    k.append(x0, x1, x2, x3, x4, x5, x60)
    print(k)
    k.plot(ch='all')
コード例 #2
0
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())
    
    print(x3)
    print(x3.peak())
    print(x3.rms())
コード例 #3
0
ファイル: ex_append.py プロジェクト: adrian-stepien/zignal
@copyright: (c) 2015 Ronny Andersson
@license: MIT
'''

# standard library
from __future__ import print_function
import logging

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

if __name__ == '__main__':
    logging.basicConfig(format='%(levelname)-7s: %(module)s.%(funcName)-15s %(message)s',
                        level='DEBUG')
    
    fs  = 10000
    f0  = 10
    dur = 0.1
    
    x1  = Sinetone(f0=f0, fs=fs, duration=dur+0.2, gaindb=0)
    xn  = Noise(fs=fs, duration=dur, gaindb=-20)
    x   = Audio(fs=fs)
    
    print(x)
    
    x.append(xn, x1)
    del x1, xn
    
    print(x)
    
    x.plot(ch='all')
コード例 #4
0
ファイル: ex_noise.py プロジェクト: adrian-stepien/zignal
'''
Created on 16 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 Noise, Audio

if __name__ == '__main__':
    logging.basicConfig(format='%(levelname)-7s: %(module)s.%(funcName)-15s %(message)s',
                        level='DEBUG')
    
    fs  = 96000
    dur = 1.0
    
    nw  = Noise(fs=fs, duration=dur, gaindb=-6, colour='white')
    np  = Noise(fs=fs, duration=dur, gaindb=-6, colour='pink')
    x   = Audio(fs=fs)
    x.append(nw, np)
    
    print(nw)
    print(np)
    print(x)
    x.plot_fft()
コード例 #5
0
ファイル: ex_comment.py プロジェクト: adrian-stepien/zignal
'''
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 Audio

if __name__ == '__main__':
    logging.basicConfig(format='%(levelname)-7s: %(module)s.%(funcName)-15s %(message)s',
                        level='DEBUG')
    x = Audio()
    print(x)
    
    x.comment(comment="We can add comments\nthat spans multiple lines.")
    
    print(x.comment())
    print(x)