Samplepack – Spectrum AY sample playback made easy

I’ve used a fair bit of sampled sound in my recent Speccy productions, and when you’re using a cross-assembler like Pasmo that lets you shuffle PC-sourced data around in the Spectrum memory without really thinking, it’s easy to forget what a big deal that is. Up until now, high quality* samples have been out of reach of people who would rather not mess around with assemblers… and so, by popular demand, I’ve put together this pack that will let reasonably-competent Basic programmers convert WAV files and play them back on the Spectrum’s AY sound chip. Instructions, source code and example files are included in the package, so go and have a play – if it means more digitised gameshow hosts in the Crap Games Compo, I’ll be happy…

Download Samplepack (ZIP, 73Kb)

* The term “high quality” is, of course, relative. We’re talking 4-bit audio as opposed to 1-bit here.

Update (2007-05-30): Windows users of the world can now rejoice, for Karl McNeil has rewritten the sam2ay.pl script in FreeBasic, neatly avoiding the need to install Perl, and packaged the whole shebang up with other essential tools to do the WAV to TAP conversion all in one go. Download WAV2AY (328Kb)

Update (2007-10-11): Another update from Karl McNeil… the latest WAV2AY package now includes a utility to batch-convert a folder of WAV files and allow them to be played back on command from the 128/+2′s ramdisk. Download WAV2AY v2 (1.0Mb)

Update (2009-09-06): Karl McNeil has released version 3 of WAV2AY, with some mostly cosmetic tweaks that shuffle everything into one seamless executable package. It works a bit faster too… Download WAV2AY v3 (1.0Mb)

Update (2010-06-02): And here’s version 4 (which Karl actually put together a while back but somehow it got buried in my inbox – oops, sorry!), with a new Windows GUI… Download WAV2AY v4 (1.5Mb)

Update (2012-09-21): WAV2AY version 5 (1.7Mb) is now up on WOS, which is probably a more reliable place to check for any future updates to the tool :-)

20 Responses to “Samplepack – Spectrum AY sample playback made easy”

  1. Factor6 says:

    Hey Gas! It works perfectly! It’s easy just for such a lame person like me :)

    For OS X users who don’t want to bother compiling SoX, here is an alternative audio file format converter:

    http://www.nch.com.au/switch/

  2. YERZMYEY says:

    For such lame person like me it’s total magic.
    Can’t use it and understand nothing.
    But it might be interesting if these samples would suit to SAMPLE-TRACKER………?!!??
    Actually its own sample-sets get to be boring. It would be more that required to have new samples for the prog.
    What d’ya say, Matt?????????????????????

  3. matt says:

    Mmm, interesting thought… I don’t know for sure what the format of Sample-Tracker samples is, but it’s quite probably the same format as this (or maybe the same but with high and low bits swapped – that’s easily fixed) – in which case, yes, this could be used for Sample-Tracker! We’d have to experiment to find out the correct sample rate to use, but that’s not too hard. I shall investigate…

  4. Karl McNeil says:

    Iv been looking for something to do straight Wav conversion for ages… Was a bit miffed off at having to download Perl in order to use it though, so I thought Id write a FreeBasic equivilent of your excellent Perl script:

    REM :: FreeBasic Version of RAW2AY convertor
    REM :: This version by K.McNeil 2007, May 29
    REM :: Original done in Perl by Matt Westcott

    InFile$=”Output.raw”
    OutFile$=”Output.ay”

    Open InFile$ FOR BINARY AS #1
    Open OutFile$ FOR OUTPUT AS #2

    Let B$=”": Let B=0: Let lo=0:Let hi=0

    DO WHILE (NOT EOF(1))
    Let B$=INPUT$(1,#1): Let B=ASC(B$)
    If (b

  5. Karl McNeil says:

    Hmmmmm…. seems the blog page won’t let me display the whole routine…

  6. Karl McNeil says:

    Perhaps you could make us non-perl users life a little easier and compile your script into Binary?….

    Thanks again for a wonderful program…

  7. Karl McNeil says:

    …Now, if only we could convince the great Sergey Bulba to include such a feature into his excellent Ay Player…?

    ..?

  8. Karl McNeil says:

    Iv written a small update: batch.exe converts more than one WAV file at a time, for dumping on the 128k silicon disk, and gives the option to relocate player code and sample data…

    Iv emailed the script to Gasman, and if he thinks its not too primitive, he might kindly let it linger here for public use????!… ;)

  9. Bruno Florindo says:

    Nice. I will be waiting for such script. Thanks Karl.

  10. matt says:

    Oops, looks like I ended up sitting on Karl’s updated version for a couple of months! It’s up now… sorry Karl, and thanks to Bruno for the reminder :-)

  11. [...] to convert the video to a series of files in a .TAP file. Then I used a lightly tweaked version of Gasman’s Samplepack code to convert the audio into a bunch of little files, on for every frame. Then I wrote another quick [...]

  12. [...] Kinda Ooh.avi – 3:13, 640×352, 25 frames per second Goldwave VirtualDub BMP2SCR Pro v2.01 Gasman’s Samplepack code Pasmo assembler [...]

  13. roger says:

    any one figure out whether playing video in windows media player classic but altering the screen resolution for the playback to either 320×200 or the 512 screen res means that if you digitse from the video playing on the screen it will make the digitsing onto the speccy any easier or better quality
    also how do you digitse to the multitech mb-02+ velesoft datagear dma interface
    or even sam mode 2 (12kb for a screen extra 6k of colour attribute data so that the atribute squares are per byte of eight pixels rather than 64 pixels and 8 bytes
    also sam modes 3 and 4 – again higher res and more colours
    no one use line interrupts for more colours or interlaced 2 screens – velesoft still reckon the dma on a 128k can shufti 17kb per frame two multitech screens anyone!? dream on!

  14. matt says:

    Roger: LCD’s Retro-X should support every graphics mode you can think of, on the Spectrum, Sam or any of a dozen other machines. If it doesn’t, it’s in alpha at the moment, so now’s your chance to give LCD your feedback!

    I assume Retro-X will resize videos automatically, so there’s no real benefit to pre-resizing them. (Generally, the more pre-processing steps you go through, the more likely you are to lose quality.)

    As for playing those videos back… well, one thing at a time! We haven’t perfected video playback in normal modes yet… :-)

  15. Karl McNeil says:

    Hi… just emailed you an WAV2AY update… Only minor:
    - Its slightly faster (the perl script is incorporated in main script now)
    - Its DOS operations are now hidden from view (more presentable)
    - Its now a standalone single file application – ie: portable…

    …otherwise, its the same engine and BASIC code underneath…

    Enjoy…

  16. Karl McNeil says:

    Yes!.. its another update!… (well, Im in the swing of it – you know how it goes – one late night is usually followed by another…)..

    Anyhow, Iv added a simple push button interface to make it more like a windows application. Its fairly idiot proof…

    The main changes are:

    1) Its got a new userinterface with simple push buttons… (Presentation)
    2) It will assume default settings without pestering you now when processing (production is thus faster)
    3) It now allows you to pick individual files for processing, not just whole file folders (it does both)
    4) Credits are more explicitly given now where they are due…

    I figure Iv probably milked this now for all its worth, so it may be the last version for awhile…

    Binary and basic source AutoIT scripts emailed to Gasman… If he thinks its good enough, he may just upload it here… ;)

  17. Karl McNeil says:

    ReSent the last GUI version of Wav2AY…

  18. Karl McNeil says:

    WAV2AY version 5: As the version that is currently posted is dated Sept 2009, and the version I have is Sept 2011, I thought I would email Matt my ‘uptodate’ (yes, its already a year old!!) version… Iv also posted it to the WOS archive too. It does the same job but also now spits out an assembly listing to the Desktop that can be compiled on a 48k+ without the need for a 128k ramdisk. The listing uses data compression, since its intended for 48k+ users. To use it from BASIC, compile with something like Pasmo, then POKE ORGIN+3, WAV_to_PLAY, before using RANDOMISE USR ORIGIN to actually play it… The output is self explanatory… Its rough and ready, but does the job.. Its also likely to be the last version, as Iv been since swamped by other projects… Hopefully Matt will post it up soon… ;)

  19. zilog says:

    when i load the tap file my emulator just keeps showing

    PROGRAM: MAIN
    PROGRAM: MAIN
    PROGRAM: MAIN
    PROGRAM: MAIN
    PROGRAM: MAIN
    PROGRAM: MAIN
    PROGRAM: MAIN
    PROGRAM: MAIN

  20. Karl McNeil says:

    In response to Zilog… Its been awhile since I touched this tool, but I seem to recall that kind of error occurring when the WAV your trying to convert is TOO BIG… in those cases, the wav doesn’t get converted, so the .TAP file then lacks the bytes section, leaving the TAP looping endlessly in the emulator searching for the Bytes section… Solution: Try using smaller WAV samples!!!… If I ever revisit this project, I may add some error checks to warn users when their samples are too big, in future… ;)

Leave a Reply