Log In  

Basic, easy to use sound/music support is nice, but I'd love access to sound "hardware". Think of it like playing music/sound on your C64 using a mod player vs. writing a program to drive SID directly. This would give us many awesome possibilities that are either impossible or very hard to achieve with the sound system that is in Pico-8. I mean, we can access rendering hardware directly, so why not do the same for sounds?

All it would take is to add following command (name may be different, but gist about the same)

asnd waveform,freq,vol,channel

(asnd from advanced sound). It'll play waveform with specific frequency and volume (if either set to 0, it'd just stop playing it) on channel until another "regular" sound is played on that channel, either via music player or via sound command) or another asnd command is issued with that channel name. If channel is omitted, it'll play on first unused channel (with nothing playing on it).

As for waveforms, they're pretty much the same you can set in the sound editor.

P#40993 2017-05-26 09:02 ( Edited 2017-11-24 08:27)

I second this. It would then be easy to do things like siren sounds programmatically (and they could be dynamic).

P#46615 2017-11-23 05:07 ( Edited 2017-11-23 10:07)

I would LOVE for this to happen.

P#46642 2017-11-23 18:47 ( Edited 2017-11-23 23:47)

+1

P#46648 2017-11-24 01:51 ( Edited 2017-11-24 06:51)

Yeah, that would be nice.

P#46652 2017-11-24 03:27 ( Edited 2017-11-24 08:27)

Found this old post and think the request is still useful :-)

P#65595 2019-07-05 11:54
5

This can be done without much trouble, actually. You just need to create instruments using poke():

do
  local state={}
  function play(form,freq,vol,ch)
    local id=state[ch]
    if not id then
      id=flr(rnd(4))
      for k,v in pairs(state) do
        if v==id then state[k]=nil end
      end
    end 
    state[ch]=id
    local n=63-id
    local p=0x3200+68*n
    poke(p,band(freq,63)+band(form,3)*64)
    poke(p+1,band(vol,7)*2+band(form,4)/4)
    poke2(p+66,256)
    sfx(n,id)
  end
end

Here is an example of how to use it:

a=0
function _update60()
  a+=.01
  play(0,50+10*sin(a),5,"wave 1")
  play(1,30+20*rnd(),5,"rand")
  play(6,20+5*sin(2*a),5,"noise")
end
P#65696 2019-07-08 08:31

Perfect! (I was already doing tests with code quite similar to this! :-) )

P#65699 2019-07-08 13:31

Wow. May I use your code, Sam?

P#65709 2019-07-08 21:28

Sure, it’s all free to use and modify.

P#65736 2019-07-10 07:57

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 21:33:27 | 0.009s | Q:25