SimH PDP-8 simulator plays music

Randy Dawson rdawson16 at hotmail.com
Thu Apr 6 01:12:53 CDT 2017


Kudos!


That is awesome Kyle, and sounds great.


Have you had a look at Max B. Mathews MUSIC4BF?


Old FORTRAN dusty deck I want to bring up, it is not realtime like yours, but calcs wavetable (or DAC) output for later processes.


Anybody found the source for this?


Randy


________________________________
From: cctalk <cctalk-bounces at classiccmp.org> on behalf of Kyle Owen via cctalk <cctalk at classiccmp.org>
Sent: Wednesday, April 5, 2017 7:43 AM
To: General Discussion: On-Topic and Off-Topic Posts
Subject: SimH PDP-8 simulator plays music

I suspected that I could somehow get some music out of the SimH PDP-8
simulator for a while now, if I could only make it run real time and toggle
a GPIO pin fast enough say, on a Raspberry Pi. That may still be doable in
the future, but I also had a suspicion that I could generate music not in
real time.

I finally got around to trying out my idea last night. A few lines were
added to pdp8_cpu.c to spit out the elapsed instruction cycles every time a
CAF instruction is executed, the default "noise" instruction in the MUSIC.PA
program.

That's all I did to the simulator. I then ran MUSIC with a given .MU file
and watched as many integers are spit out onto the screen. These were
copied and pasted into a new text file and saved.

The rest of it is in a single C program that I cobbled together. It reads
in this new text file and generates a series of pulses as an array of
floats. Each interval is about 1.93 microseconds, which I calculated to be
the average number of pulses for the music program to be "in tune" with
A=440 Hz, plus or minus. This value is subject to change, particularly as
the notes get higher in frequency, but only by perhaps 6% or so from my
experiments. One detail to note is that per the recommendation of the
MUSIC.PA manual, these pulses are extended to roughly 6 microseconds, or
three time intervals in my program.

This array of floats is then downsampled use libsamplerate to 44.1 kHz
(from 1/1.93 microseconds, or roughly 520 kHz) and output to a canonical
WAV file, 16-bit single channel.

What do you know, it worked! Here's a sample:
https://www.youtube.com/watch?v=_urDcyluX9c
[https://www.bing.com/th?id=OVF.X4rar%2fthDhiKS0hGfDpAGA&pid=Api]<https://www.youtube.com/watch?v=_urDcyluX9c>

Maple Leaf Rag - SimH PDP-8<https://www.youtube.com/watch?v=_urDcyluX9c>
www.youtube.com
I made a hacked version of SimH's PDP-8 simulator which outputs timestamps every time a certain instruction is executed. When used with the music program, MU...



My code can be found here, for those interested:
https://github.com/drovak/music

Presumably, this technique could be used to generate music from any given
computer simulator.

Thanks,

Kyle


More information about the cctech mailing list