#!/usr/bin/env python # coding: utf-8 # In[1]: get_ipython().run_line_magic('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) # In[8]: slot.send_event(0, 42, 32, fm, 0, 0) # In[9]: buf = p.fill_buffer() buf # 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) # In[13]: import matplotlib.pyplot as plt # In[14]: plt.plot(l) # 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) # 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) # In[19]: slot.play_from_beginning() # In[20]: buf = p.fill_buffer() buf # In[21]: buf_t = buf.transpose() l, r = buf_t # In[22]: Audio(buf_t, rate=p.freq) # In[23]: plt.plot(r) # In[24]: 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, 5000)