Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Is there an event trigger when sound done playing?  (Read 23691 times)

0 Members and 2 Guests are viewing this topic.

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Is there an event trigger when sound done playing?
« on: January 10, 2009, 08:51:41 pm »
I was just thinking about writing a traditional music file player (such as the old FastTracker 2 file format) in SFML.  I was looking for a way to trigger an event or some other type of hook when a sound finishes playing.

This would be useful because I need to implement a looping sample after a sample that is not looped is done playing in order for the instrument sound to be complete.  Also, the .XM file format supports what is called "ping-pong" looping where the sound playback is reversed (negative frequency on some sound cards) at the beginning and end of a looping sample.

It may be possible to do some of this already using threads but I'm not that familiar with threading.

klusark

  • Newbie
  • *
  • Posts: 45
    • View Profile
Is there an event trigger when sound done playing?
« Reply #1 on: January 10, 2009, 11:19:33 pm »
You could use a pausable clock, as long as you know how long the song is.

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Is there an event trigger when sound done playing?
« Reply #2 on: January 11, 2009, 03:30:14 am »
I'm afraid that won't work.  I'd need a pausable clock for each of 32 voices playing at the same time and a precise way to switch samples as soon as any one of them is done playing.

The idea is that most of the instruments in music module formats have a portion of the sample that doesn't loop followed by a portion that does.  Sometimes the loop requires the computer to reverse the playback direction at the end of the loop and then resume forward playback at the beginning of the loop.

Perhaps I should have posted this in the Feature Requests forum.

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Is there an event trigger when sound done playing?
« Reply #3 on: January 12, 2009, 02:14:13 am »
Here's a thought:  streamed audio requires a seamless enqueue of samples in order for there to be no skips between the buffers.  If this could be done in parallel on 32 voices playing at the same time, then it would be a practical means by which I could implement my instrument playback.

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Is there an event trigger when sound done playing?
« Reply #4 on: January 14, 2009, 02:39:06 am »
Update:  Examining the example source on the OpenAL Soft website revealed that OpenAL Soft does indeed queue samples when streaming.  I'll have to see what can be done to make a musical instrument class.