Close

Orchestra 80/85 Support

A project log for TRS-80 Model 1 on a PIC32

TRS-80 Model I emulated on a PIC32MX processor; VGA, PS/2, and SD for tape and disk images. Oh, and glourious cassette sound.

ziggurat29ziggurat29 04/28/2018 at 01:492 Comments

The PWM has been in-place for quite some time (and is used for the 'cassette sound' feature that many games use), but I had never gotten around to implementing the Orchestra 80 support, even though it should be simple.  Part of the reason was that I didn't have any software or files for it, and part was just that I had forgotten about it.

Since I had a little time today, I decided to do a little research on the web, and found a copy of the ORCH85/CMD and a few music files.  Also, I found a copy of the manual for Orch 80.

I have no idea how to run this program, and it seems I would need a minor in musicology to understand a lot of the stuff in the transcription setting, but I think I can manage loading a file and playing it.  It turns out there is a command, 'GET', which loads, 'scores', and plays the music files, so that is good enough for my testing, I think.

The hardware was trivially simple:  two I/O ports (0xb9 and 0xb5 -- seems unusual) write an 8-bit sample to a DAC for left and right channels.  The rest is all done in software.  So I coded a connection from those I/O ports to the existing PWM.

For the Olimex board, it required a little thinking:  that board only has one PWM channel.  I decided to simply average the two channels' values in that case.  Since the channels are written one at a time, I needed to store the last written value for each channel, and average those to create the effective setting for the PWM.

The initial sound output sounded pretty bad, but was recognizable.  Could it have really been this bad back in the day?  Or was it my crappy amp and speaker (a couple bucks on ebay based on an LM386, and an equally cheap speaker element probably intended for a toy)?  Or was it the output filter on the boards?  Maybe a combination of all these things?

I figured it would be best to start, if possible, with just one note.  Ideally generating a sine wave, but I couldn't figure out how to get that fancy.  But I did figure out that I could enter the music of 'W0' which meant 'a whole note of middle C'.  Then I captured that signal.  It looked like crap (sorry, I should have captured the scope trace, but I didn't), so there definitely was a weird signal going into the audio amp.

I added a little testing code to write all the values sent to a file, so I could analyse the data stream.  The data at first glance did seem to look like it probably would have generated that waveform, so I started to guess that it is a signed/unsigned problem.

I loaded the file into a waveform editor as a 'raw' file, and started with 'unsigned' (since that is the way I was interpreting it), and visually the waveform did look like the scope trace.  I re-imported it as 'signed' and then it looked much more sane (with an apparent fundamental, and some lower amplitude harmonics riding on top of that).

So, changing to unsigned is just a simple matter of an offset of 128, and that seemed to do the trick.  The scope trace looked sane, and the output was improved.  I wouldn't go so far as to say it sounds great, but it was not as bad as it was.  Maybe it would sound even better with a better amp, speaker, and filter than I am using.

The copy of the orch85 software I have on-hand is for disk, so I created a floppy image 'orch85.dmk' which has that, and some music files.  If you want to try the software, know that you need to specify some parameters on startup:

'speedup' indicates that a speedup modification was installed on the TRS-80.  Answer 'no' to this.  (much as I would like to speedup, the 80 MHz PIC32MX doesn't have enough free cycles to do it).  

Then it asks for number of voices 3/4/5.  I suggest picking '4' since that is the default and seems to be what most files are configured for.

Lastly, it asks if you want to 'save program'.  This creates a copy of orch85/cmd that has the above options burned in.  It seems to be doing a bit more than simply stamping in the parameters, because the binary diff is significant.  If you 'save program' you will be prompted for the new program name.  I called mine 'ORCH4V' to indicate it is configured for four voices.

When running the program, you can issue 'DIR' to list the ORC files on the disk.  Then you can either do the sequence of READ fname, SCORE, PLAY or your can do all three with the GET command.

Beyond that little walkthrough, you'll have to read the manual for yourself, which I included in the 'manuals' section of the SD card zip file.

Discussions

Mikael ☉. Bonnier wrote 05/07/2018 at 19:37 point

I heard all four included songs now on DuinoMite (not DuinoMite-Mini). Impressive! The DuinoMite only has mono output i.e. average of the left and right channels. Would it be possible to make stereo sound on the Duinomite using another pin?

  Are you sure? yes | no

ziggurat29 wrote 05/07/2018 at 20:47 point

In theory, yes. I'd have to study the schematic and datasheet to see what's physically possible. The Maximite is stereo on D1 and D3. The DuinoMite-Mini is mono on D0. It looks like the other pins go to GPIO, so I would think that it probably could be done.

  Are you sure? yes | no