Composer and Folder references

Just wonder if Composer is like Storyboard when it comes to folder structure

Is the following variable legite in Composer:

[lua]

_G.introTrackSnd = audio.loadStream( “Sound/Tracks/musicTrack.mp3” )

[/lua]

This is crucial for me in most  of my projects and was a real pain in Storyboard

build flattens lua folder structure, slashes become dots, for example:

project\

  main.lua

  code\

    scenes\

      title.lua

needs:

 composer.gotoScene(“code.scenes.title”)

Composer has no relationship to the path used for audio files.  (that is, the path you use for your audio files will be the same whether you use storyboard, composer, or neither)

This works in Composer and it did NOT work in Storyboard….at least the version I used some time ago

Thanx davebollinger

ok, I have a audio folder I call Tracks inside a Sound folder and I ref to it like this:

[lua]

introTrackSnd = audio.loadStream( “Sound/Tracks/theFifthAnkh_Whole.mp3” ) --this works in Simulator but NOT in builds

[/lua]

The following works of course after copying the soundtrack to the root and rewrite the code:

[lua]

introTrackSnd = audio.loadStream( “theFifthAnkh_Whole.mp3” )

[/lua]

Is there something I dont know of?

Please dont sugest to use flat structure since this wont work with my code, ok?

I would apreciate some feedback from the staff on this one :slight_smile:

I don’t see any reason why folder’s would be impacted by Composer or Storyboard.  The API’s are at a lower level.  I have my audio in an audio folder.

When “require"ing files, which is what composer and storyboard do, you use dot’s to separate the folder names.  In all other API calls you use forward slashes (”/"). 

Keep in mind case sensitivity on devices!

Thanks for the reply Rob :slight_smile:

The thing is that I have a class called Tracks that selects a folder based on witch instrument the user are playing and the dir is a global var

[lua] _G.soundDir [/lua]

and I have a table inside the class like this (I stripped away unnecessary stuff just for clearance)

[lua]

Track.instanceTable = {
[1] = {
   --Much stuff happens here :slight_smile:
   soundDir = “/Piano”,
   },
    }[/lua]

so if the current instrument is piano the variable changes to:

[lua]

_G.soundDir = Track.instanceTable[1].soundDir

[/lua]

Now, inside another class called Flute I pick up the change in the variable _G.soundDir like this:

[lua]

function Flute:changeSound()
   COver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinCOver-hd.mp3”)
   DOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinDOver-hd.mp3” )
   EOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinEOver-hd.mp3”)
   FOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinFOver-hd.mp3” )
   GOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinGOver-hd.mp3” )
   AOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinAOver-hd.mp3” )
   HOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinHOver-hd.mp3” )
   C2Over.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinC2Over-hd.mp3” )
   return true
  end

[/lua]

The result is that the user can play the malor scale with different sounds on the flute (piano, guitar, bass) from the according folders:

Sound/Piano

Sound/Guitar

Sound/Bass

This works perfect in simulator but in build I get no error, just no sound at all :frowning:

Keep in mind that I stripped away much stuff here but I feel the main issue here is folder reference that I do wrong maybe

I’d follow Rob’s advice about case-sensitivity… are you sure it’s “Sound” (capital S) and “Tracks” (T) and “Piano” §, etc?

(you said the files do play on device if you copy them to root, right?  just to rule out some weird off-standard mp3 format decoding issue that might affect device but not simulator.  any messages in the log?)

Works perfect in Simulator and nothing in terminal that signals any error. The same issues with Storyboard before I converted because of api deprecation.

So Rob:

If I, in lets say Track class do a request for an audio file inside the folder structure Sound/Tracks it would be like

[lua]

Track.myAudioFile = “Sound.Tracks.mySoundFile.mp3”

[/lua]

This must be wrong?

mySoundFile is now read as a directory inside Tracks and the same goes for mp3

How do you do this Rob when you deal with soundfiles inside folders together with Storyboard or Composer ?

I wonder why we can call a luafile inside folders with forwardslashes and without the file extensions and NOT with audiofiles??

I must obviously miss something here I hope :slight_smile:

Looking forward to your solution Rob

The sound files would be:

Sound/Tracks/mySoundFile.mp3

Only lua files being required use the dot syntax for the path.  Storyboard and Composer scenes are lua files that get required:

storyboard.gotoScene(“scenes.scene1”)  would load the file scenes/scene1.lua

Hope that clears that up.  Keep in mind devices are case sensitive, the simulator is not.  When dealing with files and hearing “It works in the sim but not the device”, this is 90% likely the cause.  But you need to run it on the device and look at the device’s console log and see what errors it’s spewing.  The simulator won’t help.  It’s working there.

Rob

Thanks Rob

Now I understood the whole thing.

The dot separation is because of the composer/Storyboard file require api that has the .lua extension embedded i the codestructure like Classes/Libs/Cars.lua would be:

[lua]

local cars = require (“Classes.Libs.Cars”)

[/lua]

and for like music files in folders I would do like:

Music/Tracks/robTheMiracleMan.mp3 

[lua]

local robTrack = “Music/Tracks/robTheMiracleMan.mp3”

[/lua]

ok, just for the record Rob……In this case, I was one of the “90%” cases you described earlier LOL

Thanks man

build flattens lua folder structure, slashes become dots, for example:

project\

  main.lua

  code\

    scenes\

      title.lua

needs:

 composer.gotoScene(“code.scenes.title”)

Composer has no relationship to the path used for audio files.  (that is, the path you use for your audio files will be the same whether you use storyboard, composer, or neither)

This works in Composer and it did NOT work in Storyboard….at least the version I used some time ago

Thanx davebollinger

ok, I have a audio folder I call Tracks inside a Sound folder and I ref to it like this:

[lua]

introTrackSnd = audio.loadStream( “Sound/Tracks/theFifthAnkh_Whole.mp3” ) --this works in Simulator but NOT in builds

[/lua]

The following works of course after copying the soundtrack to the root and rewrite the code:

[lua]

introTrackSnd = audio.loadStream( “theFifthAnkh_Whole.mp3” )

[/lua]

Is there something I dont know of?

Please dont sugest to use flat structure since this wont work with my code, ok?

I would apreciate some feedback from the staff on this one :slight_smile:

I don’t see any reason why folder’s would be impacted by Composer or Storyboard.  The API’s are at a lower level.  I have my audio in an audio folder.

When “require"ing files, which is what composer and storyboard do, you use dot’s to separate the folder names.  In all other API calls you use forward slashes (”/"). 

Keep in mind case sensitivity on devices!

Thanks for the reply Rob :slight_smile:

The thing is that I have a class called Tracks that selects a folder based on witch instrument the user are playing and the dir is a global var

[lua] _G.soundDir [/lua]

and I have a table inside the class like this (I stripped away unnecessary stuff just for clearance)

[lua]

Track.instanceTable = {
[1] = {
   --Much stuff happens here :slight_smile:
   soundDir = “/Piano”,
   },
    }[/lua]

so if the current instrument is piano the variable changes to:

[lua]

_G.soundDir = Track.instanceTable[1].soundDir

[/lua]

Now, inside another class called Flute I pick up the change in the variable _G.soundDir like this:

[lua]

function Flute:changeSound()
   COver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinCOver-hd.mp3”)
   DOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinDOver-hd.mp3” )
   EOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinEOver-hd.mp3”)
   FOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinFOver-hd.mp3” )
   GOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinGOver-hd.mp3” )
   AOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinAOver-hd.mp3” )
   HOver.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinHOver-hd.mp3” )
   C2Over.snd = audio.loadSound( “Sound” … _G.soundDir … “/flPinC2Over-hd.mp3” )
   return true
  end

[/lua]

The result is that the user can play the malor scale with different sounds on the flute (piano, guitar, bass) from the according folders:

Sound/Piano

Sound/Guitar

Sound/Bass

This works perfect in simulator but in build I get no error, just no sound at all :frowning:

Keep in mind that I stripped away much stuff here but I feel the main issue here is folder reference that I do wrong maybe

I’d follow Rob’s advice about case-sensitivity… are you sure it’s “Sound” (capital S) and “Tracks” (T) and “Piano” §, etc?

(you said the files do play on device if you copy them to root, right?  just to rule out some weird off-standard mp3 format decoding issue that might affect device but not simulator.  any messages in the log?)

Works perfect in Simulator and nothing in terminal that signals any error. The same issues with Storyboard before I converted because of api deprecation.

So Rob:

If I, in lets say Track class do a request for an audio file inside the folder structure Sound/Tracks it would be like

[lua]

Track.myAudioFile = “Sound.Tracks.mySoundFile.mp3”

[/lua]

This must be wrong?

mySoundFile is now read as a directory inside Tracks and the same goes for mp3

How do you do this Rob when you deal with soundfiles inside folders together with Storyboard or Composer ?

I wonder why we can call a luafile inside folders with forwardslashes and without the file extensions and NOT with audiofiles??

I must obviously miss something here I hope :slight_smile:

Looking forward to your solution Rob

The sound files would be:

Sound/Tracks/mySoundFile.mp3

Only lua files being required use the dot syntax for the path.  Storyboard and Composer scenes are lua files that get required:

storyboard.gotoScene(“scenes.scene1”)  would load the file scenes/scene1.lua

Hope that clears that up.  Keep in mind devices are case sensitive, the simulator is not.  When dealing with files and hearing “It works in the sim but not the device”, this is 90% likely the cause.  But you need to run it on the device and look at the device’s console log and see what errors it’s spewing.  The simulator won’t help.  It’s working there.

Rob