Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sound assets in project?

in Questions Posts: 658

I've found sound files for my Asteroids exercise. If I DL them, unzip them, and put them in Dropbox.assets, I can access them as one would hope. Is there a way to move the files into the actual project, so that they'll export with it? The only folders that show up under Codea in Files are Craft, Dropbox.assets, and Examples. None of my projects show up as folders.

Thanks!

Tagged:

Comments

  • edited May 29 Posts: 658

    Follow-up question: once I play a sound with loop=true, is there some way to stop it?

    ANS: Secret method sound:stop(). s = sound(...); s:stop;

  • Posts: 536

    @RonJeffries in the asset picker click on edit (top right) then you should be able to move assets to the project assets or the documents assets. Beware, if moving .obj files in this way the associated .mtl file is not moved (Grrrr!).

  • Posts: 1,757
    @RonJeffries - you can copy files to you project.codea file using the assets facility. I can never remember how to do this so - what I do is create a project folder in the documents(ie Codea route) and add the plist and icons file into it together with graphics sound etc resources. This gives a project root folder in the asset facility with your own icon and resources so accessing assets is easy by using asset.documents.project. ....

    I posted a description of this some time ago so I'll dig out the link, but may have to make a vid of this.
  • Posts: 658

    @piinthesky if you mean the asset picker under Assets on the front page of Codea, it does not show my project, so I can't move my files from Dropbox.assets into it.

    @Bri_G I don't understand what you said here so hope you can find and verify a description of how to do this. I hope it doesn't include editing a plist file ...

  • Posts: 536

    @RonJeffries no, inside the code when you click on the sound() to choose the asset. I hope when Simeon finalises the new asset system, we will be able move assets around outside of the code.

  • edited May 29 Posts: 1,757
    @RonJeffries - on the plist front you don't have to edit it. Just load a minimal one in, it seems to auto-update (or ignore) the actual contents of it but it works.

    Will post the link later - still searching.

    Edit:

    This thread is one:

    https://codea.io/talk/discussion/9391/models-in-assets#latest

    And this one

    https://codea.io/talk/discussion/9218/project-asset-packs#latest
  • Posts: 658

    @piinthesky wow, I didn't even know that was there. It adds them without comment, but works a treat. Excellent, thanks!

  • Posts: 196
    I'm having trouble loading sound assets into my programs, it looks like I'm not the only one...Simon, where are you ? Help !
  • Posts: 658

    at the bottom of the linked article, i show how i moved some sound assets into my project. hoping to help ...

    https://ronjeffries.com/articles/020-asteroids/asteroids-24/

  • SimeonSimeon Admin Mod
    Posts: 5,387

    @kendog400 what type of files do you have?

  • Posts: 196
    I've downloaded wav. files from internet. They are card game sounds, shuffle and deal card. This diffulcty of getting sounds into a project gives the impression apple does not want sounds in projects because their may be some sort of copy infringment.....
  • Posts: 658

    in the linked article, i show how i moved was files into my codea project.

  • SimeonSimeon Admin Mod
    Posts: 5,387

    @kendog400 definitely take a look at @RonJeffries post (the section titled "Update" down the bottom)

    To put your wav files into Codea you can also use the Files app. If you save the wav files into your On My iPad -> Codea folder in the Files app, they will show up in your sound picker under the Documents folder

  • Posts: 196
    Nothing shows up in documents folder, can't seem to paste items in folder, seem to be locked out....
    IMG-0074.PNG 96.8K
  • Posts: 196
    Is there any way to get files into this folder ?....
    IMG-0075.PNG 46.6K
  • Posts: 196
    Seem to be stuck with poor sound selection, Help !!!!!
    IMG-0077.PNG 66.2K
  • Posts: 658

    did you check my article and do like it says?

  • Posts: 196
    I took a peek, it looks like I have to put files into a dropbox folder and sync that with documents folder ??...I thought there would be an easier way.....
  • Posts: 658

    it's a few steps but works fine.

  • dave1707dave1707 Mod
    Posts: 8,464

    I posted something like this before, but I thought I’d clean it up a little. You can queue up multiple wav or mp3 files and download them. These examples are small wav files, so they download faster than you can queue them up. If you have larger mp3 files, then you can queue them up to download one by one. Just tap a file name to queue/download it. The files are saved in the Codea Dropbox folder. You can load them from the Dropbox folder into a projects Project folder. Open the project you want the files to go into. At the beginning of the program put sound() or music() statements. Then depending on what kind of file you downloaded, tap within the () of sound or music to show the asset list. Select Dropbox, then in the upper right, select Edit. Tap each file you want to move to the Project folder, then tap Add To at the lower right. Then tap the Project folder name. The files should be copied to the Project folder and can be Deleted from the Dropbox folder when done. Then remove the sound or music statement you added to the code. The tune table should contain the url of the file to download and the name you want to save it as. Include the .wav or .mp3 extension with the name.

    PS. The files don’t show up in this code until you close and reopen it. They should show when you open the project you want to move them to.

    displayMode(STANDARD)
    
    function setup()
        rectMode(CENTER)  
    
        -- table of addresses and the names to save them as. 
        tuneTable={
            {"https://www.wavsource.com/snds_2020-06-10_7014036401687385/sfx/car_x.wav","carStarting.wav"},
            {"https://www.wavsource.com/snds_2020-06-10_7014036401687385/sfx/cork_pop_x.wav","corkPop.wav"},
            {"https://www.wavsource.com/snds_2020-06-10_7014036401687385/sfx/cuckoo_clock1_x.wav","cuckoo.wav"},}
    
        queTable={} -- table of files waiting to download
    end
    
    function draw()
        background(40, 40, 50)
        fill(255)
        text("Selection",100,HEIGHT-10)
        for a,b in pairs(tuneTable) do
            fill(255)
            rect(100,HEIGHT-40*a,200,30)
            fill(255,0,0)
            text(b[2],100,HEIGHT-40*a)
        end
        fill(255)
        text("To download",350,HEIGHT-10)
        for a,b in pairs(queTable) do
            text(tuneTable[b][2],350,HEIGHT-30*a-50)
        end    
        if #queTable>0 then
            if not downloading then            
                pos=queTable[1]
                downloading=true
                http.request(tuneTable[pos][1],didLoadMusic,notFound)
            end
            text("Downloading --  "..tuneTable[pos][2],WIDTH/2,100)
        end
    end
    
    function touched(t)
        if t.state==BEGAN then
            for z=1,#tuneTable do
                if t.x>0 and t.x<200 and 
                        t.y>HEIGHT-40*z-20 and t.y<HEIGHT-40*z+20 then
                    table.insert(queTable,z)               
                end
            end
        end
    end
    
    function notFound()
        print("error with file..."..tuneTable[pos][1])
        downloading=false
        table.remove(queTable,1)
    end
    
    function didLoadMusic(data,status,headers)
        writeFile(tuneTable[pos][2],data)
        downloading=false
        table.remove(queTable,1)
    end
    
    function writeFile(fileName, data)
        print("begin write file")
        local file=os.getenv("HOME").."/Documents/Dropbox.assets/"..fileName
        local wFd, err=io.open(file, "w")
        if wFd==nil then
            print("Error creating file "..fileName.."\n\nError: "..err)
        else
            wFd:write(data)
            wFd:close()
        end
        print("done writing  "..fileName)
    end
    
  • Posts: 196
    OK, thanks...I finally got it, but I don't even know how I figured it out...one more question or spot to show, when I get to the documents section, I have no buttons or arrow to go back...Is it just me ?....I get stuck right at the documents, then I have to close codea pgm down and restart over....
    IMG-0079.PNG 96.8K
  • Posts: 789

    @kendog400 just tap outside the asset selector to close it. No need to reset program

  • Posts: 196
    I tried to tap everywhere, I think because I'm using an i-phone (6s), some of the screen is tucked away...I had an i-pad 5 long ago, but it became outdated, and codea PGM wouldn't run, now i got I-pad everything runs but screen missing some realestate.....
Sign In or Register to comment.