Mockbird
Interface Libarary and Synthesizer Setup Tool for Mockingbird-OTTO
Loading...
Searching...
No Matches
sndscape.h
1#include <cstdint>
2#include "layer.h"
3
4namespace Soundscape {
5
7struct Version {
8 std::uint8_t major;
9 std::uint8_t minor;
10};
11
21struct FWInfo {
23 std::uint16_t melodic_cnt;
24 std::uint16_t patch_cnt;
25 std::uint16_t wave_cnt;
26 std::uint16_t drum_cnt;
27};
28
45typedef struct {
46 std::uint8_t data;
49
58public:
71 SS6850Port(std::uint16_t base, bool with_reset);
78 void out(ss6850_byte data);
91 bool in_avail();
95 void drain();
96private:
97 void throw_hw_missing_exception();
98 std::uint16_t base_port;
99 // currently always zero; will change if IRQ support is added
100 std::uint8_t control_val;
101};
102
110public:
117 MPU401Port(std::uint16_t base);
141 void out(std::uint8_t data);
147 bool in_avail();
154 std::uint8_t in();
155private:
156 void out_cmd(std::uint8_t command);
157 void wait_out_rdy();
158 std::uint16_t base_port;
159};
160
185
214class Card {
215public:
248 Card(std::uint16_t port);
249
250 // Firmware interaction
267
268 // Firmware interaction: Synth configuation
298 void reset_synth(std::uint8_t program_cnt, std::uint16_t patch_cnt, std::uint16_t wave_cnt);
309 MelodicInstrument get_melodic(std::uint8_t program_nr);
320 void set_melodic(std::uint8_t program_nr, const MelodicInstrument& inst);
321
322 // MIDI synth interface
330 void send_midi_byte(std::uint8_t byte);
331private:
332 // Common part of the constructors. Required because OpenWatcom 1.9
333 // does not yet support delegating constructors.
334 void _ctor_common();
335 // Function to ensure the card is booted before initializing members
336 // like host_port
337 static std::uint16_t _ensure_booted(std::uint16_t port);
338
339 // Internal firmware interaction
340 void set_midi_port_mode(std::uint8_t mode);
341
342 // Sends any byte to host interface
343 void send_host_byte(std::uint8_t data);
344 // Sends a 14-bit value to the host interface. Asserts if data is too big.
345 void send_host_14bit(std::uint16_t data);
346 // Waits for an ACK. Throws on unexpected replies.
347 void expect_ack();
348 // Receives a host byte. Drops "data" bytes.
349 std::uint8_t recv_host_raw_byte();
350 // Receives a 7-bit data response. Throws on unexpected events (even ACK)
351 std::uint8_t recv_host_7bit();
352 // Receives a 14-bit data response combined from two 7-bit values
353 std::uint16_t recv_host_14bit();
354
355 std::uint16_t base_port;
356 MPU401Port midi_port;
357 SS6850Port host_port;
358};
359}
Interface to a Soundscape sound card running the Mockingbird-OTTO firmware.
Definition sndscape.h:214
void set_melodic(std::uint8_t program_nr, const MelodicInstrument &inst)
Sets the definition of one melodic instrument.
MelodicInstrument get_melodic(std::uint8_t program_nr)
Gets the definition of one melodic instrument.
Version get_fw_version()
Get the firmware version.
Card(std::uint16_t port)
Interfaces to the card at a specific port.
void send_midi_byte(std::uint8_t byte)
Sends a byte to the MIDI synthesizer.
FWInfo get_fw_info()
Get Synthesizer info.
void reset_synth(std::uint8_t program_cnt, std::uint16_t patch_cnt, std::uint16_t wave_cnt)
Clear software-loaded waves and synthesizer configuration.
Card()
Interfaces to the card configured by the SNDSCAPE environment variable.
MPU401-compatible ODIE communication port in UART mode.
Definition sndscape.h:109
void out(std::uint8_t data)
Sends a MIDI (OUT) byte.
MPU401Port(std::uint16_t base)
Constructs a port.
bool in_avail()
Polls whether a MIDI (IN) byte is available.
void ensure_uart_mode()
Ensures the MPU401 port is set to operate in UART mode.
std::uint8_t in()
Reads a MIDI (IN) byte (blocking).
MC6850-compatible ODIE communication port.
Definition sndscape.h:57
ss6850_byte in()
Reads a byte from the port (blocking).
void out(ss6850_byte data)
Writes a byte to the port.
bool in_avail()
Polls whether a byte is available.
void drain()
Receives bytes from the port until no more bytes are available.
SS6850Port(std::uint16_t base, bool with_reset)
Initializes the port.
Information about the synthesizer setup.
Definition sndscape.h:21
Version version
firmware version
Definition sndscape.h:22
std::uint16_t wave_cnt
number of waves supported
Definition sndscape.h:25
std::uint16_t melodic_cnt
number of melodic programs supported
Definition sndscape.h:23
std::uint16_t drum_cnt
number of drum instruments supported
Definition sndscape.h:26
std::uint16_t patch_cnt
number of patches supported
Definition sndscape.h:24
One layer of a melodic instrument.
Definition layer.h:82
Definition of a melodic instrument.
Definition sndscape.h:181
InstrumentLayer layers[4]
The four layers.
Definition sndscape.h:183
Version number, consisting of a major and minor version.
Definition sndscape.h:7
std::uint8_t major
major verison.
Definition sndscape.h:8
std::uint8_t minor
minor version.
Definition sndscape.h:9
A byte, tagged as "command" or "data" byte.
Definition sndscape.h:45
std::uint8_t data
payload byte
Definition sndscape.h:46
bool is_command
channel indicator
Definition sndscape.h:47