luaplayer.org
September 09, 2010, 10:06:41 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: IMPORTANT: Please read the following post http://luaplayer.org/forums/index.php?topic=693
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: pge.mp3: getTime / getFrame / setTime / setFrame  (Read 1199 times)
TibyAndy
Newbie
*
Posts: 14


View Profile
« on: February 16, 2010, 06:07:25 PM »

Hello.

I've been looking for some commands on 0.02, but it seems that they do not exist.
Is it hard to develop those commands?


number = pge.mp3.getTime()
Gets the current time from the MP3 being played
Parameters: none
Returns: the current time, in milliseconds, from the MP3 being played, or nil if it's stopped.

number = pge.mp3.getFrame()
Gets the current frame from the MP3 being played
Parameters: none
Returns: the current frame from the MP3 being played, or nil if it's stopped.

pge.mp3.setTime(time)
Seeks the mp3 to any time position in millisseconds.
Parameters: time (number) - the time, in millisseconds, for the MP3 to seek.
Returns: nothing

pge.mp3.setFrame(frame)
Seeks the mp3 to any time position in millisseconds.
Parameters: frame (number) - the time, in frames, for the MP3 to seek.
Returns: nothing


I was planning on doing a Rhythm game, but without these commands, it would be hard to synchronize precisely the song to the graphics.
At least, one of the "set"s and one of the "get"s would be required in order to create song previews and allow pattern edition.

Wonder if PGE Lua 0.03 is still under development...
Logged
clankfan1
Newbie
*
Posts: 40


View Profile
« Reply #1 on: February 16, 2010, 09:10:50 PM »

im pretty sure these exist look at the documentation though
Logged
TibyAndy
Newbie
*
Posts: 14


View Profile
« Reply #2 on: February 21, 2010, 07:05:01 PM »

No, they don't exist. I've already read all the documentation.

I have managed to do some MP3 skipping using LuaHMv3 and the "setPos" command. However, it just sets the next seek position of the MP3 into the file. Using some calculations (bitrate / 8 * number of seconds), I've managed to do a "almost precise" seek to any part of the MP3. Problem is that this command seems to be a little bit instable (sometimes crashes completely the homebrew), and while the current buffer is still playing, the seek does not happen.

I have already tried to do some stuff in Python and Lua...
Wonder if programming in C is the only solution... personally, I dislike C.
Logged
TheUnderminer
Sr. Member
****
Posts: 443


View Profile
« Reply #3 on: February 22, 2010, 12:17:58 PM »

LPHM shows it can be done. I think those functions would be pretty handy. PGE isn't the quickest with updates/new features tho.
Logged
Lett1
Newbie
*
Posts: 4


View Profile Email
« Reply #4 on: March 19, 2010, 11:03:25 AM »

Sorry for the bump, but I'm also requesting this.

Tried to make a music based game but I have to set the current play position to the middle of the song.

Also, how is the progress on 0.03?
Logged
emcp
Sr. Member
****
Posts: 479



View Profile
« Reply #5 on: March 21, 2010, 02:27:01 PM »

Sorry for the bump, but I'm also requesting this.

Tried to make a music based game but I have to set the current play position to the middle of the song.

Also, how is the progress on 0.03?

Read up on the MP3 format,

what you should be able to do, is read in the mp3 (dont load it, read it like a file)

get read of the frames you dont want, and then use loadfrommemory
Logged
TheUnderminer
Sr. Member
****
Posts: 443


View Profile
« Reply #6 on: March 21, 2010, 03:09:17 PM »

or just get rid of half the data. It might just search for the next readable frame. Im afraid that lett1 is looking for more flexibility tho, like skipping to the middle of the song after a few seconds of normal play. Reloading half of the mp3 at that point will probably stall your game for a sec.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!