libSunvox Sampler Questions

Multi-platform modular music creation studio
Post Reply
iamwhosiam
Posts: 2
Joined: Sun May 21, 2023 11:20 am

libSunvox Sampler Questions

Post by iamwhosiam »

I am playing around with the sunvox library to see if I can use it as a sound engine for a game I'm making. So it's pretty nice, but one issue I am having is I would like to play background music through the sampler looped and another problem is I would like to play sound effects and make sure that each instance has it's own track while it's being played so that it can finish playing out and not get restarted.

1. Is there a way to make a Sampler loop by default when using sv_send_note to start it playing?
2. Is there a way to tell if a Sampler is finished playing a sample on a track?

Or maybe there is a better way to go about this that I am missing?

edit: (realized I posted this in the wrong place, so I moved it to general.)
User avatar
NightRadio
Site Admin
Posts: 3944
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: libSunvox Sampler Questions

Post by NightRadio »

Hi!
1. Is there a way to make a Sampler loop by default when using sv_send_note to start it playing?
Hm... So you just need to start a looped sample?

2. Is there a way to tell if a Sampler is finished playing a sample on a track?
Unfortunately no.
How about a simple cyclic algorithm? Something like:
sv_send_note( track )
track = ( track + 1 ) & 31
sv_send_note( track )
track = ( track + 1 ) & 31
...
iamwhosiam
Posts: 2
Joined: Sun May 21, 2023 11:20 am

Re: libSunvox Sampler Questions

Post by iamwhosiam »

1. yup, my intention is for like a song to play while the game is going. that way the song will just loop indefinitely until I stop it.

2. that would 100% work, my only question is, I'll have like 200 or more sampler nodes loaded and over the course of the game be starting a new track over and over on all of them, which will cause all of there tracks to be playing silence. how much cpu over head will that be? does that matter if I never send the NOTECMD_NOTE_OFF to any of them?
User avatar
NightRadio
Site Admin
Posts: 3944
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: libSunvox Sampler Questions

Post by NightRadio »

1. yup, my intention is for like a song to play while the game is going. that way the song will just loop indefinitely until I stop it.
You can load WAV files with the loop points inside.
Or create SunVox project with preloaded samples. Then click EDIT button under the Sampler controllers, and activate the loop.

2. that would 100% work, my only question is, I'll have like 200 or more sampler nodes loaded and over the course of the game be starting a new track over and over on all of them, which will cause all of there tracks to be playing silence. how much cpu over head will that be? does that matter if I never send the NOTECMD_NOTE_OFF to any of them?
200 silent samplers it's almost free (in terms of CPU consumption).
You might be interested in the multisample instrument. The Sampler module can contain up to 120 samples within it, each assigned to a different note. You can create it using the multisample instrument editor by pressing EDIT under the Sampler controllers.
Post Reply