Starting Audio File 20 seconds into file
by Ray Taylor · in Torque 3D Professional · 11/28/2010 (3:10 am) · 6 replies
How do I use a "seek type" command to start the below shown audio file say 20 seconds into the audio file. You can see below how I start the audio file at the beginning of the file. I will be giving players the options to start it at 6 different places so creating new ogg files is not an option. I have 30 audio files to do this to.
I have my game close to finihed, I left this for last. I am rather new so any specific script would be helpful.
---------------------------------------
datablock SFXProfile(RevHev7Profile)
{
filename = "art/sound/Readings/RevHev7.ogg";
description = "AudioMusic";
preload = true;
};
--------------------------------------
function PlayMusic(%handle)
{
sfxPlay(%handle);
}
-------------------------------------
Current Command to get it started- PlayMusic(RevHev7Profile);
I want command to start it say 20 sec in.
I have my game close to finihed, I left this for last. I am rather new so any specific script would be helpful.
---------------------------------------
datablock SFXProfile(RevHev7Profile)
{
filename = "art/sound/Readings/RevHev7.ogg";
description = "AudioMusic";
preload = true;
};
--------------------------------------
function PlayMusic(%handle)
{
sfxPlay(%handle);
}
-------------------------------------
Current Command to get it started- PlayMusic(RevHev7Profile);
I want command to start it say 20 sec in.
#2
*****Log Output*****
about to setPosition --- (I echo this so I know the next line is the setPosition line.)
art/datablocks/audioProfiles.cs (399): Unknown command setPosition.
Object (3223) SFXSource -> SimObject
********************
script-----
datablock SFXProfile(RevHev7Profile)
{
filename = "art/sound/Readings/RevHev7.ogg";
description = "AudioMusic";
preload = true;
};
function PlayMusicTest(%handle)
{
%source = sfxCreateSource( RevHev7Profile );
//“I tried this one also, both work the same”--- %source = sfxCreateSource(%handle);
echo("about to setPosition");
%source.setPosition(20);
%source.play();
}
Current command to get it started- PlayMusicTest(RevHev7Profile);
You can see by the log, setPostion gets kicked out and the file plays from the beginning.
Any simple reason that the setPostion command is “Unknown”?
11/28/2010 (9:23 pm)
Thank you for your reply but nothing is ever that easy for me. The file still starts at the beginning. See Log Output and my script below.*****Log Output*****
about to setPosition --- (I echo this so I know the next line is the setPosition line.)
art/datablocks/audioProfiles.cs (399): Unknown command setPosition.
Object (3223) SFXSource -> SimObject
********************
script-----
datablock SFXProfile(RevHev7Profile)
{
filename = "art/sound/Readings/RevHev7.ogg";
description = "AudioMusic";
preload = true;
};
function PlayMusicTest(%handle)
{
%source = sfxCreateSource( RevHev7Profile );
//“I tried this one also, both work the same”--- %source = sfxCreateSource(%handle);
echo("about to setPosition");
%source.setPosition(20);
%source.play();
}
Current command to get it started- PlayMusicTest(RevHev7Profile);
You can see by the log, setPostion gets kicked out and the file plays from the beginning.
Any simple reason that the setPostion command is “Unknown”?
#3
Hmm, not sure. First thing I notice is that you're getting an SFXSource back and not an SFXSound here. You're still on 1.0, right? (not 1.1)
Even then, though, setPosition was already supported in 1.0 so the call shouldn't fail nonetheless.
Could you post a dump of the log you get when you do a %source.dump() immediately after sfxCreateSource?
12/01/2010 (12:45 am)
Hmm, not sure. First thing I notice is that you're getting an SFXSource back and not an SFXSound here. You're still on 1.0, right? (not 1.1)
Even then, though, setPosition was already supported in 1.0 so the call shouldn't fail nonetheless.
Could you post a dump of the log you get when you do a %source.dump() immediately after sfxCreateSource?
#4
-------------------------------------------------------------------
----------Here is my function to start sound file:---------------
function PlayMusic(%handle)
{
%source = sfxCreateSource(%handle); // %handle = RevHev7Profile
%source.dump();
echo("about to setPosition");
%source.SetPosition(20);
%source.play();
}
-------------------------------------
Here is the result of %source.dump();
Member Fields:
Tagged Fields:
Methods:
addFieldFilter() - (fieldName)
call() - ( %args ) - Dynamically call a method on an object.
delete() - obj.delete()
dump() - obj.dump()
dumpClassHierarchy() - obj.dumpClassHierarchy()
getChannel() - SFXSource.getChannel()
Returns the volume channel.
getClassName() - obj.getClassName()
getClassNamespace() -
getDynamicField() - obj.getDynamicField(index)
getDynamicFieldCount() - obj.getDynamicFieldCount()
getField() - (int index) - Gets the name of the field at the given index.
getFieldCount() - () - Gets the number of persistent fields on the object.
getFieldType() - obj.getFieldType(fieldName);
getFieldValue() - obj.getFieldValue(fieldName);
getGroup() - obj.getGroup()
getId() - obj.getId()
getInternalName() - getInternalName returns the objects internal name
getName() - obj.getName()
getSuperClassNamespace() -
getType() - obj.getType()
isChildOfGroup() - returns true, if we are in the specified simgroup - or a subgroup thereof
isEnabled() - ()
isExpanded() - Get whether the object has been marked as expanded. (in editor)
isMemberOfClass() - isMemberOfClass(string classname) -- returns true if this object is a member of the specified class
isMethod() - obj.isMethod(string method name)
isPaused() - SFXSource.isPaused()
Returns true if the source is paused or false if not.
isPlaying() - SFXSource.isPlaying()
Returns true if the source is playing or false if not.
isSelected() - Get whether the object has been marked as selected. (in editor)
onDefineFieldTypes() -
pause() - SFXSource.pause()
Pauses playback of the source.
play() - SFXSource.play()
Starts playback of the source.
removeFieldFilter() - (fieldName)
save() - obj.save(fileName, <selectedOnly>)
schedule() - object.schedule(time, command, <arg1...argN>);
setCallback() - SFXSource.setCallback( string callbackFunction )
Sets the the pitch of the source.
setClassNamespace() -
setEnabled() - (enabled)
setFieldType() - obj.setFieldType(fieldName, typeString);
setFieldValue() - obj.setFieldValue(fieldName,value);
setInternalName() - string InternalName
setIsExpanded() - Set whether the object has been marked as expanded. (in editor)
setIsSelected() - Set whether the object has been marked as selected. (in editor)
setName() - obj.setName(newName)
setPitch() - SFXSource.setPitch( F32 pitch )
Scales the pitch of the source.
setSuperClassNamespace() -
setTransform() - SFXSource.setTransform( xform )
setVolume() - SFXSource.setVolume( F32 volume )
Sets the playback volume of the source.
stop() - SFXSource.stop()
Ends playback of the source.
---------------Then my echo setPositon and error---------------------
about to setPosition
art/datablocks/audioProfiles.cs (400): Unknown command setPosition.
Object (3306) SFXSource -> SimObject
12/01/2010 (2:42 am)
Maybe that is it, I was still using Torque 3D 2009 Beta 2 and then just dragged my whole project up into Pro 1.1 Beta 3 to start working on the final sound stuff. I guess I should start fresh with Pro 1.1 Beta 3 and make all my changes in Pro 1.1 Beta 3. If setPosition wasn't in Torque 3D 2009 Beta 2, then that might be it. Is that what you suggest or does the data below tell you something different? -------------------------------------------------------------------
----------Here is my function to start sound file:---------------
function PlayMusic(%handle)
{
%source = sfxCreateSource(%handle); // %handle = RevHev7Profile
%source.dump();
echo("about to setPosition");
%source.SetPosition(20);
%source.play();
}
-------------------------------------
Here is the result of %source.dump();
Member Fields:
Tagged Fields:
Methods:
addFieldFilter() - (fieldName)
call() - ( %args ) - Dynamically call a method on an object.
delete() - obj.delete()
dump() - obj.dump()
dumpClassHierarchy() - obj.dumpClassHierarchy()
getChannel() - SFXSource.getChannel()
Returns the volume channel.
getClassName() - obj.getClassName()
getClassNamespace() -
getDynamicField() - obj.getDynamicField(index)
getDynamicFieldCount() - obj.getDynamicFieldCount()
getField() - (int index) - Gets the name of the field at the given index.
getFieldCount() - () - Gets the number of persistent fields on the object.
getFieldType() - obj.getFieldType(fieldName);
getFieldValue() - obj.getFieldValue(fieldName);
getGroup() - obj.getGroup()
getId() - obj.getId()
getInternalName() - getInternalName returns the objects internal name
getName() - obj.getName()
getSuperClassNamespace() -
getType() - obj.getType()
isChildOfGroup() - returns true, if we are in the specified simgroup - or a subgroup thereof
isEnabled() - ()
isExpanded() - Get whether the object has been marked as expanded. (in editor)
isMemberOfClass() - isMemberOfClass(string classname) -- returns true if this object is a member of the specified class
isMethod() - obj.isMethod(string method name)
isPaused() - SFXSource.isPaused()
Returns true if the source is paused or false if not.
isPlaying() - SFXSource.isPlaying()
Returns true if the source is playing or false if not.
isSelected() - Get whether the object has been marked as selected. (in editor)
onDefineFieldTypes() -
pause() - SFXSource.pause()
Pauses playback of the source.
play() - SFXSource.play()
Starts playback of the source.
removeFieldFilter() - (fieldName)
save() - obj.save(fileName, <selectedOnly>)
schedule() - object.schedule(time, command, <arg1...argN>);
setCallback() - SFXSource.setCallback( string callbackFunction )
Sets the the pitch of the source.
setClassNamespace() -
setEnabled() - (enabled)
setFieldType() - obj.setFieldType(fieldName, typeString);
setFieldValue() - obj.setFieldValue(fieldName,value);
setInternalName() - string InternalName
setIsExpanded() - Set whether the object has been marked as expanded. (in editor)
setIsSelected() - Set whether the object has been marked as selected. (in editor)
setName() - obj.setName(newName)
setPitch() - SFXSource.setPitch( F32 pitch )
Scales the pitch of the source.
setSuperClassNamespace() -
setTransform() - SFXSource.setTransform( xform )
setVolume() - SFXSource.setVolume( F32 volume )
Sets the playback volume of the source.
stop() - SFXSource.stop()
Ends playback of the source.
---------------Then my echo setPositon and error---------------------
about to setPosition
art/datablocks/audioProfiles.cs (400): Unknown command setPosition.
Object (3306) SFXSource -> SimObject
#5
This looks quite wrong and I'm quite surprised you say that you've started with B2 because this looks nothing like B2. There haven't been any significant changes to SFX between B2 and B3 and the dump here definitely predates B2 (both in format as well as content). Also, the interface actually doesn't even match 1.0 so something seems to be significantly screwed up here.
Did you happen to drag parts of Engine/source over too?
12/01/2010 (2:58 am)
This looks quite wrong and I'm quite surprised you say that you've started with B2 because this looks nothing like B2. There haven't been any significant changes to SFX between B2 and B3 and the dump here definitely predates B2 (both in format as well as content). Also, the interface actually doesn't even match 1.0 so something seems to be significantly screwed up here.
Quote:dragged my whole project up into Pro 1.1 Beta 3
Did you happen to drag parts of Engine/source over too?
#6
12/01/2010 (3:25 am)
I started the whole project in 1.5.2, then waited until B2 to move up. Whole new sound system in B2 took a while to learn, must have messed up there. All my sounds work fine though, but I can’t do the fancy things that I really need. Last week I just dragged project file from B2 into Pro 1.1 beta 3. I'm not an expert on all this, just learning (guessing sometimes) as I go. I have realized that I might not have the ability for what I need to do with the sound so I replied to someone needing work in the job forum. This looks like a good decision based on your findings. My game looks good, all triggers work, curtains all open, door swing open, fires and lamps look great. So to get a little paid help with the sound won’t be too bad. Thanks for letting me know it is messed up, I feel better about getting the help I need now.
Associate Rene Damm
Create, seek, and then play. Like this...