treeform / slappy

3d sound api for nim.
MIT License
40 stars 3 forks source link

Question about implementation #6

Open Riku5543 opened 4 years ago

Riku5543 commented 4 years ago

Hey I'm sorry to make an issue for this, but I have no idea how else to contact the developers.

So basically I'm making a text-based game, and I'd like to have sound effects and background music ready to go. The current way the library works is that you need a Source object in order to play and stop sound. However, the only way to create a Source is to use Sound.play().

So is the best way to have sound effects and bgm ready to go, to have a large sound initialization where I create a bunch of sources and stop them immediately to prevent them from hearing the sound? Then call Source.play() and Source.stop() when I need to? Or is there a better way to do this that I'm not seeing?

If there's no better way, then perhaps there can be a way to make Sources without calling Sound.play() first.

Alright thanks for listening. Again, sorry for using an Issue like this. I'm just not sure how else to ask.

xrfez commented 2 years ago
proc loadSounds(list: seq[string]): seq[Sound] =
  for idx in 0..<list.len:
    result.add newSound(list[idx])

let mySounds = loadSounds(@[myPaths])

discard mySounds[0].play
discard mySounds[1].play