Example #1
0
func (s *System) CreateSound_FromFilename(filename string, mode Mode) (*Sound, error) {
	var sound Sound
	b := makeNullTerminatedBytes(filename)
	cstr_filename := (*C.char)(unsafe.Pointer(&b[0])) // TODO: Why did I have to make this unsafe?
	var ferr C.FMOD_RESULT
	base.Thread(func() {
		ferr = C.FMOD_System_CreateSound(s.system, cstr_filename, C.FMOD_MODE(mode), (*C.FMOD_CREATESOUNDEXINFO)(null), &sound.sound)
	})
	err := base.ResultToError(ferr)
	if err != nil {
		return nil, err
	}
	return &sound, nil
}
Example #2
0
// Changes some attributes for a channel based on the mode passed in.
//
// Issues with streamed audio:
//
// When changing the loop mode, 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.
//
// Issues with PCM samples:
//
// When changing the loop mode of sounds created with with "System.CreateSound" or CREATESAMPLE, if the sound was set up as LOOP_OFF,
// then set to LOOP_NORMAL with this function, the sound may click when playing the end of the sound.
// This is because the sound needs to be pre-prepared for looping using "Sound.SetMode", by modifying the content of the PCM data
// (i.e. data past the end of the actual sample data) to allow the interpolators to read ahead without clicking.
// If you use "Channel.SetMode" it will not do this (because different channels may have different loop modes for the same sound) and may click if you try to set it to looping
// on an unprepared sound. If you want to change the loop mode at runtime it may be better to load the sound as looping first (or use "Sound.SetMode"),
// to let it pre-prepare the data as if it was looping so that it does not click whenever "Channel.SetMode" is used to turn looping on.
//
// If 3D_IGNOREGEOMETRY or VIRTUAL_PLAYFROMSTART is not specified, the flag will be cleared if it was specified previously.
func (c *Channel) SetMode(mode Mode) error {
	res := C.FMOD_Channel_SetMode(c.cptr, C.FMOD_MODE(mode))
	return errs[res]
}
Example #3
0
// TODO: add more docs
// Sets or alters the mode of a sound.
// When calling this function, note that it will only take effect when the sound is played again with "System.PlaySound".
// Consider this mode the 'default mode' for when the sound plays, not a mode that will suddenly change all currently playing instances of this sound.
func (s *Sound) SetMode(mode Mode) error {
	res := C.FMOD_Sound_SetMode(s.cptr, C.FMOD_MODE(mode))
	return errs[res]
}