Commit 859e7e83 authored by Jack's avatar Jack
Browse files

added sound length computation

parent 23ad68dc
......@@ -633,7 +633,7 @@ namespace sound
sfx::sound_index_t index = lua_tonumber(L, 1);
sfx::channel_index_t channel = lua_to_or_default(L, number, 2, -1);
int32_t start = lua_to_or_default(L, number, 3, 0);
int32_t end = lua_to_or_default(L, number, 3, 31); //TODO: actual length
int32_t end = lua_to_or_default(L, number, 3, machine.memory().sound(index)->length());
machine.sound().play(index, channel, start, end);
......
......@@ -81,6 +81,17 @@ namespace retro8
uint8_t speed; // 1 note = 1/128 sec * speed
uint8_t loopStart;
uint8_t loopEnd;
int32_t length() const
{
for (int32_t l = samples.size() - 1; l > 0; --l)
{
if (samples[l].volume() > 0)
return l;
}
return 1;
}
};
struct Music
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment