Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : CMM2: WAV music + WAV sound effects?
Author | Message | ||||
jaholmes Newbie Joined: 21/09/2020 Location: United StatesPosts: 2 |
(CMM2 noob alert) Is there a straightforward way to play non-MOD (e.g. WAV) background music and still use WAV sound effects? User manual and my own experimentation suggest not, but I do miss things. Wrapping a WAV in a MOD seems doable in theory (and hilariously hacky), though I wouldn't be surprised to learn that it came with memory and/or performance issues. Best, Aaron |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
Wrapping a WAV in a MOD works very effectively. Simultaneous separate WAVs isn't possible. However, if you copy a WAV into an array, you can have 1 of the 2 DACs play this array. Look at Martin Scragg's Max-E-Man game to see how he pulled this off. Visit Vegipete's *Mite Library for cool programs. |
||||
jaholmes Newbie Joined: 21/09/2020 Location: United StatesPosts: 2 |
Ah! That's excellent. Thank you. The code even manages to be straightforward. I'll give that a shot. Best, Aaron |
||||
hitsware2 Guru Joined: 03/08/2019 Location: United StatesPosts: 705 |
Is there a way to open a mod file in a text editor ? my site |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
No, a MOD file is binary. You need a 'MOD tracker" program of some sort. Visit Vegipete's *Mite Library for cool programs. |
||||
hitsware2 Guru Joined: 03/08/2019 Location: United StatesPosts: 705 |
How about a .wav file ? Someways ( long ago ( with an Amiga ) ) it would play files derived mathematically . Like a graph . my site |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
You can put a waveform into an array and feed it to DAC. Each array element should be numbers in the range 0-4095 to suit the 12-bit DACs. Here is a silly demo: ' DAC Demo Program ' create a waveform in an array and send it to a DAC for sound playback. wave_length = 31415 dim integer wave(wave_length) math set 2047, wave() ' initialize array to mid-voltage ' fill array with a silly waveform ' use a sin wave as the base, shift the frequency around and fade out at the end for i = 0 to wave_length fade = 1 if i > wave_length * 0.9 then fade = 10 * (wave_length - i) / wave_length wave(i) = 2047 + 2000 * fade * sin(i/(4 + sin(i/3141))) next i ' play the waveform. use interrupt to play only once done = 0 dac start 10000,wave(),,DAC_INT done = 0 ' Why this line? Seems to be an immediate interrupt? Mysterious. do : loop until done ' wait for sound to end end '*************************** sub DAC_INT done = 1 end sub I do not understand why line 20 is required. Comments? Visit Vegipete's *Mite Library for cool programs. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8567 |
Bug - fixed in V5.05.06b14 - I hope |
||||
Print this page |