PlayMusic PlayheadSample, PlayheadTime ?

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.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #11442

    Diffrenzy
    Keymaster

    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 ?

    #11444

    AdamStrange
    Participant

    just get .Length and a few divides will give you the time played

    #11445

    Diffrenzy
    Keymaster

    @adamstrange : probably just being slow here, but could you explain a bit more?

    #11446

    Pakz
    Participant

    As 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.

    #11447

    Diffrenzy
    Keymaster

    Thanks 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.

    #11448

    Pakz
    Participant

    Ok. I have not worked with streaming music yet. It is good though to have a number of good features to work with.

    #11449

    AdamStrange
    Participant

    ok using a somthing:Sound
    and getting the position with channel.PlayheadSample

    soundthing.Duration = length in time which is

    Property Duration:Double()
    Return Double( _length ) / Double( _hertz )
    End

    So

    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

    #11450

    Diffrenzy
    Keymaster

    Thanks, but that does not solve the issue:  channel.PlayheadSample  returns bufferposition not song position.

    Buffer is much shorter than the music.

    #11463

    AdamStrange
    Participant

    AHA, got you. OK, this is definitely a more interesting issue that maybe Mark should look at.

    Probably add a command for music position

    #11464

    scurty
    Participant

    Do 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.

    #11496

    Diffrenzy
    Keymaster

    @scurty: As you can see I’m looking for a more accurate way.

    What “Sound Extension” are you using ( and what is it? ) 🙂

    #11502

    Mark Sibly
    Keymaster

    Should be possible, I will look into it.

    #11521

    Diffrenzy
    Keymaster

    Thanks!

    #13221

    Diffrenzy
    Keymaster

    This is now in the latest develop versions of Monkey2, thanks Mark!

    Check out bananas/musictest.monkey2 that now has timed lyrics. 🙂

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.