Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
retro8
Commits
859e7e83
Commit
859e7e83
authored
Dec 21, 2019
by
Jack
Browse files
added sound length computation
parent
23ad68dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/vm/lua_bridge.cpp
View file @
859e7e83
...
...
@@ -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
);
...
...
src/vm/sound.h
View file @
859e7e83
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment