diff options
author | Grissess <grissess@nexusg.org> | 2016-06-14 02:44:27 -0400 |
---|---|---|
committer | Grissess <grissess@nexusg.org> | 2016-06-14 02:44:27 -0400 |
commit | bb38c09530d7e66182c0db5205c15b143f3d5a9b (patch) | |
tree | e3bc3b9a408b05380b08c8e7a5526a9896a461bf /packet.py | |
parent | 368b5db51d76c162656abd26c88991f0f7f8a556 (diff) |
Modwheel stuff, floating-point amplitude
Diffstat (limited to 'packet.py')
-rw-r--r-- | packet.py | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -13,14 +13,16 @@ class Packet(object): def FromStr(cls, s): parts = struct.unpack('>9L', s) return cls(parts[0], *parts[1:]) + def as_float(self, i): + return struct.unpack('>f', struct.pack('>L', self.data[i]))[0] def __str__(self): - return struct.pack('>L'+('L'*len(self.data)), self.cmd, *self.data) + return struct.pack('>L'+(''.join('f' if isinstance(i, float) else 'L' for i in self.data)), self.cmd, *self.data) class CMD: KA = 0 # No important data PING = 1 # Data are echoed exactly QUIT = 2 # No important data - PLAY = 3 # seconds, microseconds, frequency (Hz), amplitude (0-255), port + PLAY = 3 # seconds, microseconds, frequency (Hz), amplitude (0.0 - 1.0), port CAPS = 4 # ports, client type (1), user ident (2-7) def itos(i): |