На что способен PC Speaker

    Now known as the "system speaker", or simply "squeaker", PC Speaker was born in 1981 with the first IBM personal computer .. Heir to several generations of large computers for serious business, he was from birth was intended only for the filing of the simplest system signals, and could not adequately prove himself in voicing the entertainment programs that dominate the home market. Strongly inferior to sound chips of specialized gaming systems, disappearing into the shadows of soon emerged advanced sound cards, it was supported by many developers on the residual principle - as an option, giving at least some sound in the absence of the best alternatives. With infrequent exceptions, the speaker played through roughly simplified, completely monophonic versions of melodies, originally composed for much more powerful devices.

    Music album "System Beeps" written for PC Speakerusing the same basic technique from the old games, and according to the typical formula of retro-computer near-demoscene creativity, it is intended to uncover for many years the remaining unexplored potential of this simplest sound device. Actually, you can listen to the result and form your opinion on the success of this event at Bandcamp or in the video below, and further text goes deeper into the speaker’s device, the project’s history and ways of achieving a similar result for those who want to know more.


    PC Speaker Device


    Technically, the speaker is a small speaker or piezo emitter, directly controlled by one of the channels of the system timer 8253, which divides the input clock frequency of 1.19 MHz into a 16-bit value specified by the program. To get sound, the counting mode is used, in which the timer produces a square wave, that is, a square wave. This is a small, but still a step forward compared to the sound of earlier or budget computers like Apple II and ZX Spectrumwhere the speaker was simply connected to a one-bit I / O port, and the processor was obliged to generate sound. Using the timer channel allows the processor to simply select the desired pitch and continue doing other things. However, the processor can programmatically synthesize sounds of various kinds and true polyphony. PC Speaker cannot sound louder or quieter, softer or brighter. All that he can do without constant processor intervention is squeaking or not squeaking at a given pitch with the same constant timbre.

    When playing sound effects or music, the processor updates the state of the speaker — turns the sound on or off and changes its pitch — at certain intervals. As a rule, these changes occur in the interrupt from the zero channel of the same system timer. Standard is 18.2 Hz, but games often change this value upwards, in the range from 30 to 200 Hz, depending on the game.

    The effective range of frequencies available to the speaker is approximately 100..2000 hertz. Although other frequencies can be set, a variety of problems begin outside the specified range. Firstly, the speakers used in themselves do not reproduce these frequencies very well. Secondly, a noticeable deviation of possible frequencies from note frequencies begins above 2000 Hz, and when the sound frequency falls below the speaker’s update frequency, the updates start to operate late, the timer does not update the frequency divider until the count period with the previous divider ends .

    Monophonic polyphony


    Since the speaker is capable of playing only one sound channel or “voice,” that is, only one frequency at a time, and for musical purposes this is not enough, programmers and music authors sought ways to obtain imaginary or real polyphony. There are three main approaches.

    In the first approach, the speaker generates sound as usual, the music player updates the sound frequency with a timer at a certain frequency and almost does not load the processor. But at the same time, two or three virtual channels with different parts are simultaneously played, and the frequency and sound on / off values ​​are in turn derived from them to the real speaker in each update. For example, with two channels, in the first update, the sound from the first virtual channel is output, and in the next, from the second one. Similarly implemented polyphony in gamesLotus III and Xenon 2 . Since often one virtual channel plays a bass line and another melody, and these parts have pauses, it turns out alternating either distant notes from each other, or alternating notes and silence, which leads to constant cod, unpleasant for the ear. It can bereduced byeliminating pauses in batches, as in Golden Ax , which significantly impairs expressive means (pauses in music are just as important as notes), or by turning off the channel alternation when there is a pause in one of them. which gives a clearer single-note sound, as in Stunts .

    The second approach can be observed in games Lucas ArtIn which the quality of speaker versions of music has traditionally received more attention. As a rule, they predominantly consist of a single-voice melody with rare inserts of time-separated bass and rhythmic elements, interrupted by very short and abrupt sounds of a second, auxiliary channel part, such as arpeggios or drums. In other words, the channels alternate not constantly, but only in short moments of time, when the second voice drowns out the first. Examples can be heard in Monkey Island , Loom , Indiana Jones games , and perhaps the most advanced version of the arrangement in Zak McKracken and the Alien Mindbenders . This creates a more convincing and listenable illusion of polyphony, albeit a rather limited one.

    In the third approach, the speaker does not generate sound by itself, but is used as a D / A converter, through which sound or digitizing software, programmed by the processor, is played. This process requires significant computational resources, almost completely loading the usual 8086, so the method gained popularity with the spread of 80386. The quality of the sound played in this way is low and objectively inferior even to the simplest homemade Covox from a handful of resistors, but at that time it was an impressive achievement, by one of the implementations of which, RealSound , even a patent was issued and the technology was sublicensed.

    Turning a speaker into a DAC can be done by simply turning the sound off and on with a banned account, which gives the simplest 1-bit DAC, or by using the timer sound channel to generate short pulses of various lengths at a frequency set by the system timer (PWM), which turns it into a better quality 6-bit DAC. The first version can be heard in multichannel music in Fantasy World Dizzy and Hard Drivin ' games , the second is more often used for playing music based on samples, for example, in Pinball Dreams . It was also used in such interesting projects of the past as TEMU and VSB - software emulators of the three-channel Tandy sound chip and the digital part.Sound Blaster , allowing in the absence of these devices to output the sound intended for them through the speaker (requires 386SX and higher).

    Album and history of creation


    Initially, I didn’t have a plan to make a music album. There was a creative search for an audiovisual image for a game project with styling for pseudographic games of the XT era, and for the maximum authentic image, an idea arose to write not just styling, but music really possible on PC Speaker , following the classical 8-bit musical formula of games - looped tracks lasting about minutes I would not like to use digital sound or software synthesis, since the result would hardly correspond to the spirit of the era, and would not have a special character. Monophonic melodies have been the subject of my interest since the time of the ZX Spectrum and my acquaintance with the games Ping Pong , Stardust , Score 3020. And since there was such a case, I wanted to try to write exactly one-voiced music, but to get some unusual result at the expense of the arrangement is a tempting challenge for the composer.

    The work on music was even more exciting than the work on the game. In the process of burning the idea was developed and published VSTi plugin PCSPE , made a few sketches and melodies proof cover versions of old tracks to develop the technique of working with odnogolosy arrangements and find common solutions in sound. Later it became clear that the result did not correspond to the vision of the game project, and the project itself gradually went to the table. But the musical material remained, and the heard potential suggested that it would be nice to quickly arrange it in the form of a small separate collection of melodies forMS-DOS , at least as a demonstration of the capabilities of the plugin.

    It didn't work out quickly, the matter dragged on, several tracks grew into several dozen, a collection of random melodies evolved into a thematic album, plans changed, dates shifted. As a result, the completion of the idea took a half years, from July 2017 to January 2019. During this time, I managed to make AONDEMO and write a track for it (sound iron AON almost repeats PC Speaker ), and also participate in the development of sound code and utilities for the game Planet X3 , where the title track was also included as a title track.

    The completion of the project was constantly postponed, more and more new tracks were added to it, until all the initial ideas and sketches were completely exhausted. In the final form of the album included 23 tracks, divided into three groups.

    Side A contains 16 main tracks, more or less connected by a common theme and sound. For the most part, they were composed specifically for the album, from scratch or based on old material that was well suited for a single-voiced arrangement. The principle of selection in this group was in originality and more successful, as it seemed to me, arranged in selected constraints, as compared to other tracks.

    Party Bincluded 6 tracks, presumably less successful, which were cover versions of my old works for other platforms, or were based on more or less elaborated old material, which initially assumed completely different formats - from the XM module to the pop punk song. It also included the track, already lit up in Planet X3 .

    Side X included a track from AONDEMO with minimal changes. This branch is made as a joke of humor.

    The album itself is designed as a player program for MS-DOS 3.3 and higher, which will run on the IBM PC XT with at least 256KB of RAM and a CGA video adapter . Since the original CGA cardprone to the so-called "snow", a visual artifact when trying to update the screen during the ray path on the raster, the program is presented in two versions - sbx.com without the effect of a spectrum analyzer, but without snow, and sb.com with such an effect. For smoother rendering of the analyzer, it is desirable to have a more powerful processor. Of course, more modern computers will also fit, for example, with FreeDOS loading from USB , as well as DosBox emulation .

    Musical component


    No software tricks are used in the album, such as sound synthesis by the processor and the use of a speaker as a DAC. The technology is the most traditional - a strictly monophonic square wave generated by the system timer, updating the pitch with a relatively large but not out of the ordinary frequency of 120 Hz, which is quite possible by the classical XT and leaves enough processor time to perform other tasks besides playing music.

    The whole secret is in a special approach to writing melodies and arrangements. Here, previous experience in different related areas helped a lot - the experience of writing a classic chip-tun for sound chips of the past, in which it is often necessary to combine several batches in one channel using the method of alternation and overlay; experience in developing sound engines for games on old computers, where sound effects borrow channels from music, drowning it out; as well as the experience of composing original music for the drive. As it turned out later, in fact, I developed an approach to speaker music that was used by Lucas Art , although at the time I started working I heard only a theme from Monkey Island .

    One of the interesting problems that needed to be solved almost at the beginning of work was the instruments of percussion and percussion. In chiptune, they are usually made using a noise channel, but there is no opportunity to play noise on the speaker at a refresh rate of the order of tens to hundreds of hertz.

    The bass drum and the toms work well and without noise, in the form of simple slides down at different speeds and durations - the barrel is faster and shorter from a low note, the tomos are slower and truer from the higher notes. But the main percussion instrument, a small (working) drum, in the form of a simple slide sounds unconvincing and does not cut through the mix loaded with other elements. This is a trick that is often encountered in simulating a snare drum on a SID and AY-3-8910.- short sound off at the beginning of the slide, creating a fraction effect. This makes the sound sufficiently different from other percussion instruments, and also improves the visibility of the drum in the mix. This is particularly evident in conjunction with the characteristic resonances characteristic of a real speaker.

    Due to the absence of noise, we had to abandon any hass. For a more varied and interesting sound, drum instruments differ between tracks. Somewhere they are longer, somewhere abrupt, they sound higher or lower, sometimes there are additional elements.

    In the process of working on music, universal techniques were developed, suitable for writing monophonic arrangements for any monophonic devices that do not have volume control, whether it be a music card, a CNC machine or a Tesla coil. Among them:

    • The peculiarity of human hearing, when the supposedly louder sound masks the quieter sounds. For example, the drum beat or the note of the central melody - they divert attention to themselves and make the brief disappearance of the remaining parts unobtrusive.
    • Arrangement in which there is enough pauses between the notes. This is especially true of the introductory parts. At these moments, the components are well heard separately and get an opportunity to be remembered so that as the track develops, when the arrangement becomes denser, the brain continues to recognize the presence of these elements, even if they become barely audible in the mix.
    • The composition of melodies, in which a significant part of the notes falls on a weak share, as well as a shift in the beginning of the notes relative to the grid of the meter. This allows the melody notes to take up pause spaces in the accompaniment, thereby reducing the imposition of parts. In particular, it allows you to win some space for the notes of the bass parts, for which it is important to get into a strong beat. This gives melodies a strong sync copy, creates a feeling of funkyness, which is beneficial to their interestingness.
    • Regular chip tuners arpeggios at different speeds, including very fast two-note arpeggios at a frequency of 120 Hz. Variations in speed allow you to create elements of the arrangement with different sound, which helps a lot in the absence of timbre expressive means - after all, all notes have the sound of the same square wave.
    • Repeated pauses in extended sounds, for example in a solo instrument, in which other virtual channels are heard. As a rule, such instruments begin with a continuous sound, then pauses appear and their frequency and length gradually increase, which is a kind of imitation of a falling volume.
    • Variations of the duration of the notes, including very short, to simulate the difference in volume. It is used to emphasize ripple in bass parts, where notes falling on a strong beat have an increased duration, as well as to create an echo effect — when the part with notes of the same duration echoes itself, but with notes of significantly shorter duration.



    Technical component


    Another key point in the work on the album is the use of modern tools that make it much more comfortable and efficient. This is a familiar to me modern digital studio Reaper (a program similar to FL Studio , Cubase and the like) and a set of independently developed VST plug-ins.



    Such an approach is experimental, completely unconventional to create a "tru-chiptune", that is, music intended to be played on a real device - usually special programs-trackers or manual typing of musical data are used for this. Of course, the same result can be obtained with such more classical means (which was done for Planet X3), but it requires more effort and regular distraction from the creative process to purely technical points.


    Especially for the creation of speaker music was developed VSTi plugin PCSPE . It emulates PC Speaker hardware , allowing you to immediately hear a near-to-real result, and also implements a system of chip tuners, like those used in trackers for various sound chips. Virtual volume envelopes (priority), arpeggios and pitch changes are set as lines of text with a very simple format, reminiscent of the MML music programming language (relative to the lines of letters in the PLAY operator in BASIC). Using these envelopes, you can set, for example, various sounds of percussion instruments, or a solo instrument with gradually increasing vibrato.

    But the main task of the plug-in is to automatically mix several input MIDI tracks with different parts into the final mono track. The mentioned virtual loudness of the instruments is the basis of the priority system. At one point in time (the period of updating the state of the speaker), only the instrument with the highest current volume always sounds. For example, the bass instrument has a volume of 2, the melodies are 6, and the instruments of the drums have a volume of 8, which means that the notes of the melody will drown out the notes of the bass, and the drums will drown out both. Thus, several simultaneous sounding musical parties are reduced to one speaker channel.

    The plugin has the export function for the further use of music in real programs. The principle of the log is used: the plugin always knows what frequency is given to the emulated speaker at each time point, and how much time passes between its changes. When you turn on the export function and play the track from the beginning to the end, this data is recorded in real time in a file of the selected format. Further, in order to play music, it is enough to take this data from a file and output it to a real speaker with the required delays.

    Typical ChipTun Arpeggios can be created in PCSPEin the classical way corresponding to the envelope defining the sequence of offsets in semitones relative to the base note. But it requires constantly switching instruments and keeping in mind the correspondence between the instruments and the resulting chords. To do this in modern DAW is rather inconvenient.

    A much more convenient way is implemented by my other VSTi plugin - the ChipArp arpeggiator , specially designed for writing ChipTunes and styling. It automatically converts traditional polyphonic chords from the input MIDI track to arpeggios with the specified parameters into the output MIDI track, and does it on the fly - you can play MIDI chordskeyboard and immediately hear the arpeggio. Unlike arpeggiators for modern electronic music, which constantly restart a note from the beginning, this plugin implements arpeggios in the form of pitch bands with respect to the lowest note of a chord. Thus, the arpeggio does not violate the long-lasting sound of the instruments. For the full-fledged operation of this plugin, it is necessary to support the installation of a wide range of bands and an instant reaction to bands in the synthesizer plugin used, which is rare, but all my synthesizers support this.

    PCSPE and DosBox emulatorsgive an idealized square wave, markedly different in sound from the real device. Tiny system speakers are subject to strong resonances and distortion of the frequency response, emphasizing the transients, that is, the moments of switching on and off the sound or a sharp change in frequency. In particular, this makes the drums on a real speaker much more pronounced in the mix, i.e. "Punch". For the control and handling of such a feature for the benefit of the arrangement, the free NadIR plugin was used and the recorded impulses of several small speakers were recorded by hand - just like the impulses of real guitar cabinets are used for digital recording of guitars.

    Materials


    The project was published under the open license CC-BY , including the music itself, the sources of the player and the projects of all tracks for Reaper. Thus, anyone is free to make any derivative products, both with respect to the musical component and the code. All the tools used in the development are also available in conjunction with the sources:

    Player
    software with music Program sources and projects for Reaper
    PCSPE plugin with sources
    ChipArp plugin with sources
    Speakers pulses

    Also popular now: