ndary Posted June 8, 2021 Share Posted June 8, 2021 Hi Guys, i am looking for a simple routine that can play wav (sample voice) sounds on the atari 8bit (with antic on) any one can direct me to information or the link to a previous thread discussing this issue. thanks ndary Quote Link to comment Share on other sites More sharing options...
+MrFish Posted June 8, 2021 Share Posted June 8, 2021 @Irgendwer posted source code for the sample routine he used in Disc O' Pop. 3 Quote Link to comment Share on other sites More sharing options...
ivop Posted June 8, 2021 Share Posted June 8, 2021 (edited) Playing samples (page aligned) is basically: mwa #sample zp ldy #0 loop lda (zp),y ora #$10 ; optional, if you preset the volume-only bit sta WSYNC ; repeat for lower sample rates sta AUDC1 inc zp bne loop inc zp+1 lda zp+1 cmp #>samplend bne loop This is with unpacked 4-bit samples. With packed 4-bit, it's something like: mwa #sample zp ldy #0 loop lda (zp),y tax :4 lsr ora #$10 sta WSYNC ; repeat for lower sample rates sta AUDC1 txa and #$0f ora #$10 sta WSYNC ; repeat etc... sta AUDC1 inc zp bne loop inc zp+1 lda zp+1 cmp #>samplend bne loop Untested live coding in the AA editor, but you get the drift If you want to keep the screen on, you have to disable VBIs and DLIs. You can also run the replay routine from a timer IRQ at 15.6kHz, or 7.8kHz, etc... Edited June 8, 2021 by ivop Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted June 8, 2021 Share Posted June 8, 2021 Quote Link to comment Share on other sites More sharing options...
Rybags Posted June 9, 2021 Share Posted June 9, 2021 (edited) Pokey Timer is the best method especially if the screen is displaying something. Wait on WSync or VCOUNT is OK also but means the CPU is at 100% and also ties you to that particular sample period (or multiple of) Simple delay loop is a primitive method and not well suited if a display is present as you get way too much variation in the real time elapsed. Edited June 9, 2021 by Rybags Quote Link to comment Share on other sites More sharing options...
ndary Posted June 9, 2021 Author Share Posted June 9, 2021 Hi Ivop, how you convert the WAV file to raw sample data? what too you use? 13 hours ago, ivop said: Playing samples (page aligned) is basically: mwa #sample zp ldy #0 loop lda (zp),y ora #$10 ; optional, if you preset the volume-only bit sta WSYNC ; repeat for lower sample rates sta AUDC1 inc zp bne loop inc zp+1 lda zp+1 cmp #>samplend bne loop This is with unpacked 4-bit samples. With packed 4-bit, it's something like: mwa #sample zp ldy #0 loop lda (zp),y tax :4 lsr ora #$10 sta WSYNC ; repeat for lower sample rates sta AUDC1 txa and #$0f ora #$10 sta WSYNC ; repeat etc... sta AUDC1 inc zp bne loop inc zp+1 lda zp+1 cmp #>samplend bne loop Untested live coding in the AA editor, but you get the drift If you want to keep the screen on, you have to disable VBIs and DLIs. You can also run the replay routine from a timer IRQ at 15.6kHz, or 7.8kHz, etc... Quote Link to comment Share on other sites More sharing options...
Rybags Posted June 9, 2021 Share Posted June 9, 2021 Usually a given PC based utility will only work down to 8-bit samples. I've always just used a quick self-written program to convert. Use input of either 16 or 8 bit (preferably unsigned) sample data. Either throw away the lower bits (integer divide) or use rounding to get 4 bit samples. Then pack those samples, high/low into 8 bits and output to a file which then is read into the Atari. 2 Quote Link to comment Share on other sites More sharing options...
ivop Posted June 9, 2021 Share Posted June 9, 2021 9 hours ago, ndary said: how you convert the WAV file to raw sample data? what too you use? I used to use sox to convert to 8-bit 7800Hz unsigned, or 8-bit 15600Hz unsigned, and save as RAW. Then I used to have (can't find it) a small tool that divides all bytes by 16 (shift right four times). Be sure to use a SINC resampling to avoid aliasing, and normalize so your 8-bit sample with only 7-bits dynamic range won't turn into a 3-bit sample. You can also export to WAV so you can replay it at your PC to listen to the quality. Reexport as RAW when your done, or cut-off the first 44 bytes of your final WAV file. 1 Quote Link to comment Share on other sites More sharing options...
ndary Posted June 9, 2021 Author Share Posted June 9, 2021 (edited) Hi Ivop, "You can also export to WAV so you can replay it at your PC to listen to the quality. Reexport as RAW when your done, or cut-off the first 44 bytes of your final WAV file." This is something i can do with AUDACITY ndary Edited June 9, 2021 by ndary Quote Link to comment Share on other sites More sharing options...
+CharlieChaplin Posted June 9, 2021 Share Posted June 9, 2021 I usually convert the 16Bit stereo WAV into 8Bit mono WAV with Wavosaur or Audacity, then transfer the WAV to the Atari and there convert the 8bit mono WAV into a 4Bit mono sample... just for fun. (And some days ago I also converted approx. 20 MP3 songs into 8Bit mono WAV and kept only the first 5-10 seconds of them, then transfered them to the A8 and saved them on ATR images together with The Sound Utility by CTH/Tom Hunt which is a WAV player for 8bit mono WAVs on the A8; it supports XRAM up to 1MB.) There are many other ways to convert a WAV into an A8 sample, e.g. I have some old PC files that work under WIN XP command prompt and a) convert WAV into sample (and sample into WAV), named WAV2SMP.EXE as well as b) convert 16Bit mono WAV into 4Bit mono sample, named Convert4.EXE. wav_conv.zip 2 1 Quote Link to comment Share on other sites More sharing options...
ivop Posted June 10, 2021 Share Posted June 10, 2021 17 hours ago, ndary said: This is something i can do with AUDACITY Yes. Load WAV file, convert to mono, resample to 15600 (Tracks->Resample), export as 8-bit WAV. Not sure if the resampler is a proper resampler, so best do a low pass filter on half the replay rate (7800Hz in this case) on the original WAV file and then reample to 15600. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted June 10, 2021 Share Posted June 10, 2021 somewhere in the forum I might have posted the IRQ sample player I got from Space Harrier XE coder and I used that in Gridrunner. Miker did all the sample conversion on PC for it. something like every 2nd scanline IRQ was fired to play a byte of sample. not sure if it was 4bit nibble packed. tooo long ago or me getting old 1 Quote Link to comment Share on other sites More sharing options...
+CharlieChaplin Posted June 11, 2021 Share Posted June 11, 2021 Here you will find "The Sound Utility" by CTH (a Wavplayer for the A8 and some WAV2SMP converters for the A8). Quote Link to comment Share on other sites More sharing options...
Xuel Posted June 12, 2021 Share Posted June 12, 2021 Here's an example that I made for ndary in PM: sample.zip The Makefile shows the sox commands that you can use to convert to 8-bit raw files with sample rates of either 4k or 8k. It also shows a Perl one-liner to convert 8-bit raw files to 4-bit raw files. Run test.xex and press 1-5 to hear various techniques and sounds: 4bit 4k sample rate "barrel roll" 8bit 4k sample rate "barrel roll" 2X RAM consumption 4bit 8k sample rate "barrel roll" 2X RAM consumption 4bit 4k sample rate "bubblegum" 8bit 4k sample rate "bubblegum" 2X RAM consumption 2 Quote Link to comment Share on other sites More sharing options...
+CharlieChaplin Posted June 13, 2021 Share Posted June 13, 2021 There is also Audio Master which should be able to load WAV and save as SMP. And here is a sample converter that may also do the job (untested). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.