-
Notifications
You must be signed in to change notification settings - Fork 1
/
testrfx.py
60 lines (59 loc) · 1.59 KB
/
testrfx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#! /usr/bin/env python3
# -*- coding: UTF-8 -*-
# CLI tester for RFX synth
# used during synth development
# $ python -i testrfx.py
import RFX
import wx
import wx.adv
import sys
from collections import deque
App=wx.App()
s=wx.adv.Sound()
stack=deque(maxlen=5)
def p():
"""Plays the sound at the top of the stack, or nothing if stack is empty."""
try:
s.CreateFromData(stack[-1].Create())
s.Play()
except IndexError:
pass
def r():
"""Adds a randomized sound to the stack."""
stack.append(RFX.SFXRWave.randomize())
p()
def m():
"""Adds a mutation of the last item to the stack."""
try:
stack.append(stack[-1].mutate())
p()
except IndexError:
print("Nothing to mutate.")
def undo():
"""Undoes the last operation, returns to previous item on stack."""
try:
stack.pop()
p()
except IndexError:
print("Nothing to undo.")
def l(s):
"""Loads a sound from the string given as the single argument."""
try:
g=RFX.SFXRWave()
g.load(s)
stack.append(g)
p()
except ValueError:
print("Bad data")
def w(name):
"""Writes the current item to a wave file given by the single parameter.
Parameter must not have extension."""
try:
f=open(name+'.wav','wb')
f.write(stack[-1].Create())
f.close()
except IndexError:
print("Nothing to write")
def g():
"""Just gets the last item on the stack and returns it. Useful for changing synth params."""
return stack[-1]