About Monkey 2 › Forums › Monkey 2 Development › PlayMusic PlayheadSample, PlayheadTime ?
This topic contains 13 replies, has 5 voices, and was last updated by
Diffrenzy
1 year, 2 months ago.
-
AuthorPosts
-
November 3, 2017 at 9:53 am #11442
PlayMusic() is a great addition.
Would it be possible to make PlayheadSample, PlayheadTime return the total time/total samples played, and not the buffer position?
I’m asking because I’m making a project, where visuals are syncd to audio, and it would be great to be able to do this on longer pieces of music.
Maybe the channel could have an “accumulated” time/sample property ?
November 3, 2017 at 11:42 am #11444just get .Length and a few divides will give you the time played
November 3, 2017 at 11:46 am #11445@adamstrange : probably just being slow here, but could you explain a bit more?
November 3, 2017 at 12:13 pm #11446As far as I am aware the music(mp3,wav,ogg) plays at a certain amount of bits per second(1000 MIllisecs) If you know at which bitrate the music file is encoded you can calculate the time you are on.
November 3, 2017 at 12:16 pm #11447Thanks Pakz, but I need better accuracy.
Soundcards and devices drift (in time), so especially when playing long files, we need sampleposition to know how far along playback is.
November 3, 2017 at 12:26 pm #11448Ok. I have not worked with streaming music yet. It is good though to have a number of good features to work with.
November 3, 2017 at 2:10 pm #11449ok using a somthing:Sound
and getting the position with channel.PlayheadSamplesoundthing.Duration = length in time which is
Property Duration:Double()
Return Double( _length ) / Double( _hertz )
EndSo
time position would be along the lines of:
channel.PlayheadSample / (channel.Pitch * sound.Hertz)I’ve not tried it, but that is the sort of thing you need to look at
November 3, 2017 at 2:12 pm #11450Thanks, but that does not solve the issue: channel.PlayheadSample returns bufferposition not song position.
Buffer is much shorter than the music.
November 4, 2017 at 6:39 am #11463AHA, got you. OK, this is definitely a more interesting issue that maybe Mark should look at.
Probably add a command for music position
November 4, 2017 at 6:51 am #11464Do you mean the time from which said track/sound started playing?
Cuz I do that via Millisecs() from a Sound Extension. Start a virtual timer from x.Play()
Then stop the timer from x.Pause()/Stop()
Idk, maybe I don’t understand the question. Aha.November 5, 2017 at 10:14 am #11496@scurty: As you can see I’m looking for a more accurate way.
What “Sound Extension” are you using ( and what is it? )
November 5, 2017 at 6:55 pm #11502Should be possible, I will look into it.
November 6, 2017 at 3:19 pm #11521Thanks!
January 25, 2018 at 3:04 pm #13221This is now in the latest develop versions of Monkey2, thanks Mark!
Check out bananas/musictest.monkey2 that now has timed lyrics.
-
AuthorPosts
You must be logged in to reply to this topic.