STE background audio player

  Regular TOS on Atari STE computers is single-tasking. Same is with TOS versions used on TT and Falcon. But we want to play some music while doing editing, programming and similar.
Desktop accessories are partially multitasking, and I made player as ACC. But ACC handling in TOS is not really suitable for constant backgroound playback, so ACC is used only for  giving commands to player and see status. Audio playback self is controlled from regular interrupt, what required special file access techniques - and result is pretty constant playback while doing regular operations as opening windowses, menus etc. Even starting some application will not interrupt playback if disk access is enough fast and executables are not very large.

  System requirements:  Atari STE, Mega STE, TT or Falcon computer with hard disk. About 140 KB free RAM . If want to convert during playback program needs 200 KB free RAM. It means that may work even on 512KB machines.
  Key features:  background audio playback with max possible STE quality :  50066Hz, 8-bit, stereo digital sample  playback. Supports: 50066Hz, 8-bit mono, 25033Hz stereo and mono too.
  Max datarate is 100 KB/sec, what is achievable even with slow Satandisk.  GUI with playback progress bar etc. Practically unlimited audio file length (limit is partition size).  Playlist support.   100% ASM. - fast and compact code.

  Main goal was to make background player with minimal system load during audio play, direct from hard disk. Therefore playback of only STE compatible PCM formats is supported. In practice it means that before first playback we must convert audio source file in proper format.  When it is ready playback in max quality will load average STE + hard disk about 15 % .
  Disk space usage:  max quality files take 6 MB/minute. Min quality quart of that, so 1.5 MB/minute. On 512 MB partition can place therefore some 80 minutes of stereo, 50066 Hz audio (max. qual.). Or about 20 average songs.  So, ideal for people having problems with filling their Atari disks :-)


   Usage of program:
  Copy  STEBPL09.ACC in ROOT of C partition. Restart computer.  You will have Desk menu item STEBPL, and can enter control dialog, shown on pic above.
  All control goes with mouse.  Playback of files with WAE extension is supported. But at begin you will have none of such. So, must convert your MP3, WAV files to that format.  It goes in 2 steps: see at bottom of this page how to convert to proper WAV file on PC (no plans to make that part of conversion on Ataris - it will be very slow). Second part of conversion is with our program: click on 'Convert WAV' and select file. If it is in proper format program will convert it to WAE file in short (or little longer) time (what depends mostly from hard disk speed). Conversion self is just conv. to signed format - as I don't see PC SW what can do signed, STE compatible WAV files. After conversion done you may delete src. WAV file to save disk space. Or prg. will do it for you, if check ' delete WAV ...' button.
  Button with ethernity symbol is for playing again from start when reach end of file or list - when checked on, of course. You may check/uncheck during playback too.  Progress bar shows current file playback progress. + user may jump to desired part of audio by simple mouse click there.  Jump may be not immediate, especially by lower quality audios - this is background player in first place, jump handling code is very simple.
  As this is background player we can do even WAV conversion during playback :  then little more free RAM is needed, but is possible even with 512KB machines if no other SW running. Don't try it with Satandisk though - it is too slow for that.
  Volume setting works on STE and TT, not on Falcon.  Clicking Exit button leaves dialog, but playback continues. Then may run some other APP, performing Desktop operations.
But there are limitations what is possible to do without crash and other troubles:
  Possible is:  running regular GEM SW as diverse editors, database handlers etc.  Graphic programs what use not special tricks - Degas will work. Spectrum 512 and other like ones maybe not.
  Do not run:  games, debuggers, system affecting SW and similar. It is not enough to just stop playback - you need to restart with deactivated ACC .

  And of course, program takes some RAM ( ~ 140 KB ) - so better 'run' it not if plan not to use.  'run' here means  loading ACC after restart.  Experienced Atari  users know how it goes:  Change extension to AC instead ACC for instance and restart. Or use some boot manager, even better - use selectable C partition option if your hard disk driver allows it .

  Changing Desktop resolution:  solved to not crash when it is selected. Of course, playback will stop as ACC will be reloaded by res. change.

  Compose playlist :  for now simple 'composing' is implemented:  select DIR with your WAE files in file selector, type in desired filename (no need to type extension), or select existing one (which will be overwritten) .  Program will make list with all WAE files which are in same DIR as selected (typed in) PLS file .
Such list will contain only filenames, without path, in order as they are in DIR (unsorted). Changing order is possible with some editor.

  The Playlist: simple textual file with extension PLS . Can make it with usual editors.


  Filenames, separated with pressing  Enter key .  If only filename is given it must be in same DIR as list file. Otherwise full path must be given - third line.
  Must press Enter key after last item (line) too, and then save file to get proper format.
  If repeat is checked on,  list playback will continue with first item after finishing last one.
  PLS file size is max 1024 bytes. Any extra data will be ignored.

Known issues:

             Pressing Esc key in Desktop while partition from which playback goes is opened will result in something known from era of vinyl analog disks: repeating short part of audio constantly.
            The reason is that TOS refreshes, reinits that partitiona and closes all opened files from. I did not add workaround for it with intention - it is good way to purge out too many opened files, what may happen in case of starting-closing APPs many times during playback.

   Download - version 0.9 alpha .  With proper format WAV file - old heavy metal for complete retro feeling :-)

   Direct playback without conversion:  Fast code

   New:  loss-less packing
  It is possible to pack STE compatible audio data, without quality loss, and playback so packed data with CPU load of about 50-60% on 8MHz STE - stays for max quality.  Packing is based on fact that by usual CDA source (so clean)  difference between adjacent samples is less than 7% in about 95% cases. It means that we can use delta system, where instead literal store difference to previous sample. With it can spare 4 bits in output sample datas.  And it means 1/2 of data, because 4 is half of 8 ! Talking about 8-bit samples, of course.  In practice, best packing is achievable with 50066 Hz audio - packed data is size of 55-60 % of non-packed.
With 25033 Hz packed size is usually around 65-70% . The reason is that with lower samplerate average diff. is always higher.
  All in all, possible to have quality audio playback where datarate is around 3.5 MB/min, and with CPU load of 50% for depacking.

  Player project - non background

  Spare version:   p/SteBapSpar.png

Very simple GUI, with minimal set of buttons. Clicking on Play/Stop button will open File Selector if no playback active, or will just stop active playback.
User may open WAV or WAE type files (filename extensions).  WAV is regular Windows format audio file, and must be with following parameters:  stereo, 8-bit PCM, 50066 Hz samplerate.
It means that you need to convert your existing audio files in that format. There is a lot of SW on PC capable to do it. I will not go here in that. And no plans to do SW for conversion on Atari - that is possible of course, but would work pretty much slow.  After selecting WAV with fileselector program will convert it to WAE format, used by playback self. Conversion may take some minutes - depending on file length and hard disk speed (on Satandisk aprox 2 x  audio duration) . But this conversion needs to be made only once and after it you may delete org WAV file on Atari disk. Purpose is to make playback minimum possible system loading. When conversion is finished click again on Play/Stop button and select WAE file. Playback will start immediately.  You may adjust volume on STE and TT with arrows lower - it works not on Falcon.
  Checking on Repeat button means that after finishing playback of selected file it will start again, and again ...  Clicking on Exit button leaves our small dialog, and then may run some SW or doing Desktop operations. Even file copy and similar.
  Possible is:  running regular GEM SW as diverse editors, database handlers etc.  Graphic programs what use not special tricks - Degas will work. Spectrum 512 and other like ones not.
  Do not run:  games, debuggers, system affecting SW and similar. It is not enough to just stop playback - you need to restart with deactivated ACC .
  Do not try to change Desktop resolution - it will crash. If need different res, must deactivate ACC and reset Atari. Then Save Desktop in wanted res. and activate back ACC, and reset again.
  This is fixed in later versions .
   Unlike NED player (only one STE direct from disk player I saw with background play possibility) here will be no interrupts and noticeable slowdowns (except with very slow drive as Satandisk) by window operations, program starts etc. If start playback in some APP and exit to Desktop it will play still, without error message.

   Download - version 0.45 alpha . Source included.  With 1 min long  WAV file .


  Preparing WAV file on PC :
  Audacity 1.3x  is good freeware audio processing program. Windows, Linux, MAC OS ... versions. Converting some WAV,  MP3  to  STE suitable format is very easy and fast with :
 pea  stopPlay(pc)
  After opening source audio file  enter  50066  or  25033 to field 'Project Rate (Hz)' at bottom left.  May convert to mono with  Tracks, Stereo Track to Mono if want mono.
 Then:  File, Export : p/ACExport.png

   Select 'Other uncompressed files' , then 'Options' and set WAV (Microsoft) , Unsigned 8 bit PCM  :


  Don't enter any Metadata - just click OK :
  In case that there are some entries you must remove them all .


  We have now almost fully STE compatible WAV file. Only thing what is requred yet is conversion to signed format, what will be done with our player, on Atari (or may do with emulator on PC).
  Take care that WAV filename be in DOS 8.3 format - rename by need.  'My Song.wav'  to  MYSONG.WAV  for instance. 


  As I see using dither by resampling may couse more noise. It looks like: in total silent places AudaCity generates not 0 output, but there are small variations +1, 0, -1 in. It may cause noise, clicking, especially on STE. So, recommended to set dither to 'None' in preferences.

 Technical background - for interested people:
   Because Atari machines are very slow and limited in compare to modern, or even 15 years old PCs, we need to make SW like this with pretty much different approach.
Forget all packed audio formats - decoding would slowdown too much, usually below playability. And we want minimal system load. So, playback only from prepared audio files, with RAW PCM audio content, in STE compatible format. That's the reason why we need above mentioned parameters. As usual PC SW can not produce signed PCM used by STE, our program will do it by opening WAV file. After conversion WAE file is in 100% STE compatible format, and will playback with about 10-20 % system load on STE with usual disk speeds  500-1000 KB/sec.
  Lack of multitasking in TOS requires some tricky programming. Using ACC's quasy-multitasking is not the best way considering speed and system load. I made it using Timer-C as playback controll handler. Other problem is that ACC is not threated as separated process by TOS, so if you start playback in some APP and quit it you will loose file handler, as TOS will close by APPexit all handlers opened in that APP - it stays for ACC too, as 'child' of APP. This is why NED player stops playback in mentioned case. I added code to override this problem. And it is why no Desktop res. change is allowed.
  Whole system works pretty stable by my testings. If user takes care what is possible and what not to do ...  Side effect of handler loose problem may be too many opened handles in case of starting a lot of programs and exiting them during playback.  Even it is possible to cure:  open C in Desktop and press Esc key - refresh . It will result in playback like on old scratched vinyl disks - repeating short part endless.  The reason is that TOS reinits partition C in such case and part of it is closing all file handlers. So, player can not load selected audio file. I did not added reopen for such case with intention - using refresh by hard disks is not usual operation, but pressing it here is good way to clean up too much opened handlers.


    P. Putnik,   Latest update: April  2011.