Example #1
0
// Retrieves the loop points for the channel.
func (c *Channel) LoopPoints(loopstarttype, loopendtype TimeUnit) (uint32, uint32, error) {
	var loopstart, loopend C.uint
	res := C.FMOD_Channel_GetLoopPoints(c.cptr, &loopstart, C.FMOD_TIMEUNIT(loopstarttype), &loopend, C.FMOD_TIMEUNIT(loopendtype))
	return uint32(loopstart), uint32(loopend), errs[res]
}
Example #2
0
// Sets the loop points within the channel.
//
// loopstart: Loop start point, this point in time is played so it is inclusive.
//
// loopstarttype: Time format used for the loop start point (see "TimeUnit").
//
// loopend: Loop end point, this point in time is played so it is inclusive.
//
// loopendtype: Time format used for the loop end point (see "TimeUnit").
//
// If a sound was 44100 samples long and you wanted to loop the whole sound, loopstart would be 0, and loopend would be 44099, not 44100.
// You wouldn't use milliseconds in this case because they are not sample accurate.
//
// Issues with streamed audio:
//
// When changing the loop count, sounds created with "System.CreateStream" or "CREATESTREAM" may have already been pre-buffered and executed their loop logic
// ahead of time before this call was even made.
// This is dependant on the size of the sound versus the size of the stream decode buffer (see CREATESOUNDEXINFO).
// If this happens, you may need to reflush the stream buffer by calling "Channel.SetPosition".
// Note this will usually only happen if you have sounds or loop points that are smaller than the stream decode buffer size.
func (c *Channel) SetLoopPoints(loopstart uint32, loopstarttype TimeUnit, loopend uint32, loopendtype TimeUnit) error {
	res := C.FMOD_Channel_SetLoopPoints(c.cptr, C.uint(loopstart), C.FMOD_TIMEUNIT(loopstarttype), C.uint(loopend), C.FMOD_TIMEUNIT(loopendtype))
	return errs[res]
}
Example #3
0
// Returns the current playback position for the specified channel.
//
// Certain timeunits do not work depending on the file format. For example "TIMEUNIT_MODORDER" will not work with an MP3 file.
func (c *Channel) Position(postype TimeUnit) (uint32, error) {
	var position C.uint
	res := C.FMOD_Channel_GetPosition(c.cptr, &position, C.FMOD_TIMEUNIT(postype))
	return uint32(position), errs[res]
}
Example #4
0
// Sets the playback position for the currently playing sound to the specified offset.
//
// position: Position of the channel to set in units specified in the 'postype' parameter.
//
// postype: Time unit to set the channel position by. See "TimeUnit".
//
// Certain timeunits do not work depending on the file format. For example "TIMEUNIT_MODORDER" will not work with an MP3 file.
//
// If you are calling this function on a stream, it has to possibly reflush its buffer to get zero latency playback when it resumes playing, therefore it could potentially cause a stall
// or take a small amount of time to do this.
//
// If you are using "NONBLOCKING", note that a stream will go into "OPENSTATE_SETPOSITION" state (see "Sound.OpenState") and sound commands will return ERR_NOTREADY.
// "Channel.Position" will also not update until this non-blocking setposition operation has completed.
//
// Warning! Using a VBR source that does not have an associated seek table or seek information (such as MP3 or MOD/S3M/XM/IT) may cause inaccurate seeking if you specify
// TIMEUNIT_MS or TIMEUNIT_PCM. If you want FMOD to create a PCM vs bytes seek table so that seeking is accurate, you will have to specify "ACCURATETIME"
// when loading or opening the sound. This means there is a slight delay as FMOD scans the whole file when loading the sound to create this table.
func (c *Channel) SetPosition(position uint32, postype TimeUnit) error {
	res := C.FMOD_Channel_SetPosition(c.cptr, C.uint(position), C.FMOD_TIMEUNIT(postype))
	return errs[res]
}
Example #5
0
// Sets the loop points within a sound.
//
// loopstart: The loop start point. This point in time is played, so it is inclusive.
//
// loopstarttype: The time format used for the loop start point. See "TimeUnit".
//
//loopend: The loop end point. This point in time is played, so it is inclusive.
//
// loopendtype: The time format used for the loop end point. See "TimeUnit".
//
// If a sound was 44100 samples long and you wanted to loop the whole sound, loopstart would be 0, and loopend would be 44099, not 44100.
// You wouldn't use milliseconds in this case because they are not sample accurate.
// If loop end is smaller or equal to loop start, it will result in an error.
// If loop start or loop end is larger than the length of the sound, it will result in an error.
//
// Issues with streamed audio. (Sounds created with with "System.CreateStream" or FMOD_CREATESTREAM).
// When changing the loop points, sounds created with "System.CreateStream" or FMOD_CREATESTREAM may already have been pre-buffered and
// executed their loop logic ahead of time, before this call was even made.
// This is dependant on the size of the sound versus the size of the stream decode buffer. See FMOD_CREATESOUNDEXINFO.
// If this happens, you may need to reflush the stream buffer. To do this, you can call "Channel.SetPosition" which forces a reflush of the stream buffer.
// Note this will usually only happen if you have sounds or looppoints that are smaller than the stream decode buffer size.
// Otherwise you will not normally encounter any problems.
func (s *Sound) SetLoopPoints(loopstart uint32, loopstarttype TimeUnit, loopend uint32, loopendtype TimeUnit) error {
	res := C.FMOD_Sound_SetLoopPoints(s.cptr, C.uint(loopstart), C.FMOD_TIMEUNIT(loopstarttype), C.uint(loopend), C.FMOD_TIMEUNIT(loopendtype))
	return errs[res]
}
Example #6
0
// Retrieves the length of the sound using the specified time unit.
//
// Certain timeunits do not work depending on the file format. For example TIMEUNIT_MODORDER will not work with an mp3 file.
// A length of 0xFFFFFFFF usually means it is of unlimited length, such as an internet radio stream or MOD/S3M/XM/IT file which may loop forever.
//
// Warning! Using a VBR source that does not have an associated length information in milliseconds or pcm samples (such as MP3 or MOD/S3M/XM/IT) may return
// inaccurate lengths specify TIMEUNIT_MS or TIMEUNIT_PCM.
// If you want FMOD to retrieve an accurate length it will have to pre-scan the file first in this case.
// You will have to specify FMOD_ACCURATETIME when loading or opening the sound. This means there is a slight delay as FMOD scans the whole file when loading the sound to find
// the right length in millseconds or pcm samples, and this also creates a seek table as it does this for seeking purposes.
func (s *Sound) Length(lengthtype TimeUnit) (uint32, error) {
	var length C.uint
	res := C.FMOD_Sound_GetLength(s.cptr, &length, C.FMOD_TIMEUNIT(lengthtype))
	return uint32(length), errs[res]
}