In [1]:
%matplotlib inline
In [2]:
from sunvox import Slot, Process
from sunvox.buffered import int16, float32, BufferedProcess
In [3]:
p = BufferedProcess(data_type=float32, size=44100 * 2)
In [4]:
from rv.modules import Fm
from rv.project import Project
In [5]:
project = Project()
fm = project.new_module(Fm, m_feedback=42)
project.connect(fm, project.output)
In [6]:
slot = Slot(project, process=p)
In [7]:
slot.volume(256)
Out[7]:
0
In [8]:
slot.send_event(0, 42, 32, fm, 0, 0)
Out[8]:
0
In [9]:
buf = p.fill_buffer()
buf
Out[9]:
array([[  0.00000000e+00,   0.00000000e+00],
       [  1.85560353e-07,   1.85560353e-07],
       [  7.49872697e-07,   7.49872697e-07],
       ..., 
       [ -2.24900004e-02,  -2.24900004e-02],
       [ -1.25729879e-02,  -1.25729879e-02],
       [ -2.81969481e-03,  -2.81969481e-03]], dtype=float32)
In [10]:
buf_t = buf.transpose()
l, r = buf_t
In [11]:
from IPython.display import Audio
In [12]:
Audio(buf_t, rate=p.freq)
Out[12]:
In [13]:
import matplotlib.pyplot as plt
In [14]:
plt.plot(l)
Out[14]:
[<matplotlib.lines.Line2D at 0x10800ca20>]
In [15]:
S, freqs, bins, im = plt.specgram(r, NFFT=512, Fs=p.freq, noverlap=500, cmap=plt.cm.gist_heat)
plt.xlabel('Time')
plt.ylabel('Freq')
plt.ylim(0, 20000)
Out[15]:
(0, 20000)
In [16]:
p = BufferedProcess(data_type=float32, size=44100 * 5)
In [17]:
slot = Slot('../../../sunvox_dll/resources/test.sunvox', process=p)
In [18]:
slot.volume(256)
Out[18]:
0
In [19]:
slot.play_from_beginning()
Out[19]:
0
In [20]:
buf = p.fill_buffer()
buf
Out[20]:
array([[ 0.01608396,  0.01608396],
       [-0.43299004, -0.43299004],
       [-0.40250993, -0.40250993],
       ..., 
       [-0.01479183, -0.03583915],
       [-0.00908315, -0.03091996],
       [-0.00917414, -0.03167547]], dtype=float32)
In [21]:
buf_t = buf.transpose()
l, r = buf_t
In [22]:
Audio(buf_t, rate=p.freq)
Out[22]: