Some questions about sound/audio in Stencyl...

hansbe

  • Posts: 262
Like I said, (very cryptically), I think you can unzip the soundfx.zip and copy what's in the src directory into the preview folder. Then you can do import com.anttikupla.*; from stencyl code/blocks, and start using the package. However the preview directory is kind of unstable so i don't know if this is the best way. Perhaps making the com directory read-only could be useful. Anyway this technique appeared to work for publishing, but its not transferable (i.e. you cant upload a game where this is done). And I don't know if there's any better way of doing it.

theabbott

  • Posts: 271
Thanks Hansbe!! I'll give it a go, and will be no doubt ask you for help as i run into problems!

theabbott

  • Posts: 271
I had a good crack at it today, but couldn't get anything working,

I tried unzipping the SRC to the Preview folder, but do i unzip just to the top level? or do i unzip into the scripts folder? 

Next what behaviour mode should i use? Design mode with a code block, Freeform or Code mode?

For testing, I just have a blank scene that plays an mp3 on initialisation, then I've got a button that will turn on/off one of the pre-made filters. However i've failed to get a filter behaviour working to attach to this button!

Hansbe if you could walk me through this process it'd be much appreciated.

hansbe

  • Posts: 262
I put the com directory in the preview folder. (The com directory is inside the src folder)

(Mind that everything under the com directory also appears there as it should. Copy and paste from the windows explorer zip tool only got the com directory, not the contents. )

Then in a game I add into a new script
Code: [Select]
import com.anttikupila.events.StreamingEvent;
import com.anttikupila.media.SoundFX;
import com.anttikupila.media.filters.DelayFilter;
import com.anttikupila.media.filters.FlangeFilter;
import com.anttikupila.media.filters.LowpassFilter;

and test the game, and tada it compiles !

(Actually first it didn't, since the com directory was empty. Then there was no error message, but the game failed to show up. Some error messages only appear in the log, so particularily if you work with freeform mode, you could keep this open with your favorite notepad reader, or if you started stencyl from the console you may see some message there.)

Anyhow this doesn't do anything yet. But that's up to you to figure out ;)

You can use the import statements almost whenever in AS3, so you can put them in a code block wherever and start coding, or you can use freeform mode and make some scripts.

theabbott

  • Posts: 271
You Sir, are a Gentleman and a Scholar!  Thank you so much! I'll be sure to post the results for everyone to use if i can get them working!  :)

theabbott

  • Posts: 271
Hi guys,

I've been working on this for a while now and while i can get the game to compile with the Import statements:

import com.anttikupila.events.StreamingEvent;
import com.anttikupila.media.SoundFX;
import com.anttikupila.media.filters.DelayFilter;
import com.anttikupila.media.filters.FlangeFilter;
import com.anttikupila.media.filters.LowpassFilter;

Adding a new code block with: (Which I assume is the constructor code for the filter) :

import com.anttikupila.media.SoundFX;
var sound : SoundFX = new SoundFX( new URLRequest( "beat.mp3" ) );
sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];
sound.play( );


Causes all sorts of mayhem:



Behavior: Design_3_3_SoundFX at line 47
Implicit coercion of a value of type int to an unrelated type Class.
    sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];

Behavior: Design_3_3_SoundFX at line 47
Illegal assignment to class int.
    sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];

Behavior: Design_3_3_SoundFX at line 47
Implicit coercion of a value of type Class to an unrelated type stencyl.api.engine.actor:Actor.
    sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];

Behavior: Design_3_3_SoundFX at line 47
Implicit coercion of a value of type int to an unrelated type Class.
    sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];

Behavior: Design_3_3_SoundFX at line 47
Illegal assignment to class Number.
    sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];

Behavior: Design_3_3_SoundFX at line 47
Implicit coercion of a value of type Class to an unrelated type stencyl.api.engine:GameState.
    sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];

Behavior: Design_3_3_SoundFX at line 47
Incorrect number of arguments.  Expected no more than 2.
    sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];

Behavior: Design_3_3_SoundFX at line 47
Implicit coercion of a value of type Number to an unrelated type Class.
    sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];

Behavior: Design_3_3_SoundFX at line 47
Illegal assignment to class Number.
    sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];

I guess I'd be better off working in Flash instead?

Hansbe, any more tips you can share?


 

Hectate

  • *
  • Posts: 4643
There's probably a way to do it if you can figure out how to reference the audio and import the library. Fun stuff that I can't dig into right now...

http://flashpunk.net/forums/index.php?PHPSESSID=dec21eeb6d0868135dbcf3c3ed51080a&topic=4296.msg27250#msg27250
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

theabbott

  • Posts: 271
Thanks for link Hectate! More learning for me!

hansbe

  • Posts: 262
sound.filters = [ new FlangeFilter (int = 17600, Number = 880,  Number = 0.7) ];
Causes all sorts of mayhem:
Implicit coercion of a value of type int to an unrelated type Class.
Illegal assignment to class int.
Implicit coercion of a value of type Class to an unrelated type stencyl.api.engine.actor:Actor.
Implicit coercion of a value of type int to an unrelated type Class.
Illegal assignment to class Number.
Implicit coercion of a value of type Class to an unrelated type stencyl.api.engine:GameState.
Incorrect number of arguments.  Expected no more than 2.
Illegal assignment to class Number.

Hansbe, any more tips you can share?

Try this line in stead:
sound.filters = new FlangeFilter(17600, 880,  0.7);

Also, when you add code it should go inside a class and a function/method?