MAME Floppy sound emulation

From Ninerpedia
Revision as of 21:07, 22 August 2016 by Mizapf (talk | contribs)
Jump to navigation Jump to search

MAME (or its subproject MESS) shows impressive precision for the emulation of arcade and computer systems. One thing that has been slightly out of scope was the emulation of physical phenomena outside of the computer system, in particular the sounds and noises that occur when you operate these systems.

Motivation

Don't you remember those days when you were listening to your floppy drive? I don't mean those new projects where you play music with a floppy drive, of course. Disk operations took quite some time, compared to the flash drives nowadays. The Commodore 64 was well known for its superb games, but also for its dreadfully slow floppy drive, the C1541. When we dediced to play some of the bigger games, we often put some water in the coffee machine in the meantime, prepared some snacks, or did some other urgent things, and about two minutes later, loading was complete.

Luckily, the TI floppy system was much faster, but when you wanted to work productively, saving long texts or assembling or compiling programs, the floppy operation still was annoyingly slow.

Also, floppy disks were never 100% reliable, and their quality degraded over time. There were often read or write errors that showed up right at the end of loading, or when the program was almost built. These errors did not go unnoticed, though: The floppy drive started to produce uncommon noises when the head moved over the disk several times, while the controller tried to load or to write a sector.

Programs did not run flawlessly in those days either, just like today. Unlike today's operating systems with their powerful process management features, the home computers frequently crashed when something went wrong. In combination with the unreliable disk media, loader programs sometimes crashed, which was not guaranteed to be obvious; it just quietly locked up. You, however, kept waiting for the load process.

This is where the audible floppy drive noises came in handy. You noticed that for some time, nothing could be heard from the drive, no head movement, maybe the spindle motor stopped. In that case it was reasonable to freak out, hitting the case of that stupid old thing, vowing to get a new computer as soon as possible, just because it stopped saving your letter, with no real hope to recover it.

Floppy sounds from an emulation were one of those things that brought me into that emulation business, actually. I was astounded when I heard the UAE (Amiga emulator) loading a floppy disk, just like the real one sounded. I always wanted to have something like this in MAME. In summer of 2015 I added a first implementation for 3.5" drives which already proved to create floppy sounds quite nicely.

This is an update of these works, describing a new concept and the implementation in MAME.

Initial approach

The basic idea is quite simple, and it was quickly implemented in MAME. Floppy sounds can be produced when the floppy device (the MAME component that implements the floppy) is enhanced by another subdevice (floppy_sound_device) that is derived from a samples_device. The best way in the view of MAME would be to emulate the physics that produce the sound, which would mean to conceive a model for the resonances of the mobile and fixed parts of the floppy drive.

Trying to go for such a physical emulation opens up a giant world of dynamic systems with complicated maths and considerable requirements for the emulating systems. Also, while there is an abundance of visual rendering system, there are not that many for audio rendering, at least to my knowledge.

If we do not want to compute sounds, we have to use pre-defined sound clips or samples. This is a proper way to emulate sounds for quite a long time, appearing in many applications. For our floppy soound emulation we need to find out what sounds have to be produced:

  • The spindle motor produces a low humming sound while running. There may also be a specific start and stop sound, caused by the quick acceleration and slowing down of the rotation.
  • The floppy disk often causes a hissing sound, in particular the bigger 5.25 inch disks. The reason is that disk inside the protective enclosure stays in contact with the material. When the enclosure is slightly bent or dented, the disk produced louder noises. The smaller 3.5 inch disks have hard enclosings that leaves enough space for the disk to turn without hearable sliding.
  • The head motor and the read/write head are the components with the most obvious sound production. The head motor is a stepper motor which moves the read/write head. Stepper motors have a noticeable sound; the moving head sounds as if it locks into some hole or hits an obstacle, but this is not the case. The rapid stop of the head movement is what causes the "pop" sounds.

Taking this list into account, we can easily define our requirements:

  • We need samples of the turning disk without head movement. Since the head does not move all times, this is quite easy to accomplish; we just need to record a sample of some longer disk operation.
  • We also need samples of the head movement, the popping sounds as just mentionend.

We can treat both as two sound sources and simply add the sample values on each sample step. This creates a mix of motor and stepper sound.

This was the first approach, and it worked already quite well, but not fully convincing.

Challenges

The approach as described assumes that we can produce all sounds that we hear from the floppy by playing the motor and head samples. This is not true, though. The problem appears when we listen to a seek process, that is, when the floppy drive navigates to a farther track, crossing several track in between. If the samples were sufficient, we should get a believable seek sound by replaying the step sample.

The bad news is that this is not the true story. Let us have a look at a step sample:

Step curve.png

Full process.png

Merged seek.png

Full process ann.png

Seek20 curve.png