Howdy, Stranger!

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

Codea 2.2 Beta

SimeonSimeon Admin Mod
edited December 2014 in Beta Posts: 5,412

Hey beta testers

Codea 2.2 has a new speech API. It makes Codea talk.

This is how you use it:

speech.say("Some words")

There's a new example project (Speakeasy) and the docs are in the "Sounds" chapter.

(If you have a toddler, the example project is a fun way to get them to have entire conversations with your iPad)

Tagged:
«13

Comments

  • dave1707dave1707 Mod
    Posts: 8,578

    That looks like something I had on my Apple II back in the 70's. It was called Apple Talker. I don't remember the exact command, but it was about the same.

  • Jmv38Jmv38 Mod
    edited December 2014 Posts: 3,297

    good news.
    However, new codea beta wont install... and now it doesnt run anymore. I hope it will work again soon? Am i the only one with this problem? I have ios7.
    EDIT: i've reverted to app store version to have codea running.

  • edited December 2014 Posts: 2,043

    EDIT: got it working.

    Speech API is awesome stuff, now we just need access to the voice recognition API ;)

  • Posts: 2,161

    Bizarre bug: if I have a project with the same name as an example project, then I can't set a project icon for it. When I set the icon, it changes to the corresponding example project's icon.

  • Posts: 1,976

    First impression: Wow!

    Bug: If you close the running project while Siri is speaking, the voice continues until it runs out of text or you close Codea.

    Suggestion: speech.len(text), returns the time it would take to say specified text. Would be useful for lyrics, subtitles, etc.

  • Posts: 2,043

    Also, not sure where to post this, but there are a couple of errors in the Game Center add-ons:

    this:

    static const luaL_Reg gamecenterLibs[] =
    {
        {"enabled", gamecenter_enabled},
        {"showLeaderboards", gamecenter_showLeaderboards},
        {"showAchievements", gamecenter_showAchievements},
        {"showAchievements", gamecenter_submitScore},
        {"showAchievements", gamecenter_submitAchievement},
        {NULL, NULL}
    };
    

    should be this:

    static const luaL_Reg gamecenterLibs[] =
    {
        {"enabled", gamecenter_enabled},
        {"showLeaderboards", gamecenter_showLeaderboards},
        {"showAchievements", gamecenter_showAchievements},
        {"submitScore", gamecenter_submitScore},
        {"submitAchievement", gamecenter_submitAchievement},
        {NULL, NULL}
    };
    

    and the documentation shows gamecenter.enabled as being a boolean, but it is actually a function that returns a boolean

    finally, in the function showGameCenterWithConfigurationBlock, nothing done to codeaController seems to work, e.g. setting paused to YES followed by a print of that value shows it is still NO, and it never presents the view controller, so achivements/leaderboards never come up

  • IgnatzIgnatz Mod
    Posts: 5,396

    I have a similar problem to Jmv38, it failed to load and now it is stuck. At least I can still use Codea, but I can't test the beta.

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @Ignatz @Jmv38 really sorry, TestFlight was having some issues last night. You could try the install again.

    @Ignatz I did make some changes relating to rendering based on profiling your example. Though I haven't yet had the opportunity to test on iPad 3 to see if the changes improve performance.

    @JakAttak thank you for the corrections! The showGameCenterWithConfigurationBlock function wasn't working because the GameCenterAddon was inheriting CodeaAddon but also overrode the codeaDidRegisterAddon function (which the CodeaAddon base class uses to track the current controller). It should all be fixed in the github repo:

    https://github.com/TwoLivesLeft/Codea-Addons/

  • IgnatzIgnatz Mod
    Posts: 5,396

    @Simeon - I tried again and it worked (although I wonder what to do with the inactive icon from the first attempt!)

    I checked the speed, and it hasn't increased, BUT I also ran an earlier version of my dungeon, which is faster as I remember it, so it is probably something I added recently that slowed it down.

    In other words, the speed seems to be back where it was.

  • Jmv38Jmv38 Mod
    Posts: 3,297

    @Simeon very nice to have speech, thanks.
    Is there a difference between:

    local words = speech("Hello World")
    speech.say( words )
    

    and

    local words = "Hello World"
    speech.say( words )
    

    ?

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @Jmv38 not in that case. In the first example you get an "utterance" object, so you can use it like this:

    local w = speech("Hello")
    
    w.rate = 0.1
    w.pitch = 1.8
    
    speech.say(w)
    

    In the latter example you would have to configure those settings globally:

    local w = "Hello"
    
    speech.rate = 0.1
    speech.pitch = 1.8
    
    speech.say(w)
    
  • Posts: 2,161

    Shaders defined before setup are not being loaded. That is, putting the following in a tab outside a function (so that it is executed as the tab is read) means that the shader won't be active:

    m = mesh()
    m.shader = shader("some shader")
    

    I also find that my programs take a significantly long time to start up.

    On the plus side, setting an image as the icon is great. Is there any way to trigger the "you've taken a photo, what would you like to do with it?" programmatically? Something like:

    share(sprite)
    

    which brings up that dialog?

    A bit like how doing stopRecording() brings up the "What do you want to do with that recording?" dialog.

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @Andrew_Stacey really like the idea of being able to trigger the image share dialog programatically.

    share(img) is an interesting function name. Maybe shareImage( img ) to be more specific and to fit-in with readImage and saveImage. Will have to give it some thought.

    On shaders not being loaded outside of setup, that is likely because there is no longer any OpenGL context when your code is initially validated.

    I will profile the run performance again, I thought I had improved it but will have to see if there is anything further to be done.

  • Posts: 2,043

    Bugs:

    • Anagrams project icon was not showing up

    • After I opened and closed it, icon showed up, but it is now in the examples folder and in my normal projects area

  • SimeonSimeon Admin Mod
    edited December 2014 Posts: 5,412

    @JakAttak Anagrams should have been in the examples collection, how did it get to your normal projects area in the first place? That's very odd.

  • Posts: 2,043

    @Simeon, it wasn't there until I opened the example, then it seems to have copied itself. Opening one and closing it results in them switching spots

  • edited December 2014 Posts: 1,976

    @Simeon I found that occasionally a recently opened example project would appear in my projects, I assumed it was intentional. It always disappeared shortly afterwards.

  • edited December 2014 Posts: 2,043

    This happens for me on any example where the icon was not loaded initially, so Anagrams, Animation, and Parameters.

    Other examples don't have this bug

  • Posts: 2,161

    @Simeon So what does not having an OpenGL context mean in practical terms? It seems to affect shaders, but not meshes. Is it simply that I need to delay all shader initialisation until setup? Or is there more to it than that? How about setContext? Is that affected?

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @SkyTheCoder @JakAttak interesting. They are not supposed to get out of the examples collection. I wonder if they just appear to be going back there as part of the transition, but aren't really.

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @Andrew_Stacey generally it means no drawing, setContext would be affected too. I believe we have always disabled setContext during the validation phase.

    Every rendering, sound, and data function is disabled during this phase. That is, all rendering commands, show/hide keyboard, recording, restart, close, print, parameters, read/save data, open url, alert, and some others.

  • Posts: 2,161

    @Simeon It may just be that I've never used setContext before setup. I ran into the shader issue because there are a couple of things where I have all objects sharing the same mesh (and same shader) for efficiency so I set up the mesh when the tab is run. Now, it seems, I'll have to put that into the initialisation for when the objects are created.

    I wonder what the most efficient way to do that would be. One way would be to have a flag which is tested when each object is created and which is false initially but set to true after the first object. Another would be to have an initialisation function which destroys itself after it is run.

    INITIALISE = true
    local function doinit()
        -- do lots of complicated stuff
        INITIALISE = false
    end
    
    function Class:init()
        if INITIALISE then
            doinit()
        end
    end
    

    versus

    local function doinit()
        -- do lots of complicated stuff
        doinit = function() end
    end
    
    function Class:init()
        doinit()
    end
    

    Actually, I guess the most efficient would be to rewrite the class initialisation function.

    function Class:init()
        -- do lots of complicated stuff that only needs to be done once
        self:_init()
        Class.init = Class._init
    end
    
    function Class:_init()
        -- do the stuff that needs to be done every time
    end
    
  • SimeonSimeon Admin Mod
    edited December 2014 Posts: 5,412

    @Andrew_Stacey I see, so in the past you had a global mesh with shader and then had classes which all used it.

    You could try a singleton pattern, that's a fairly readable method:

    --# Singleton
     
    Singleton = class()
     
    local _instance
     
    function Singleton:init()
        -- Do complex initialisation
        self.value = 2 + 2
    end
     
    function Singleton.shared()
        if not _instance then
            _instance = Singleton()
        end
     
        return _instance
    end
     
     
    --# Main
     
    function setup()
     
        print( Singleton.shared().value )
     
    end

    (Where Singleton is named more appropriately for your use, e.g., MeshManager or something)

  • Posts: 1,255

    I'm seeing some issues with dependencies. Some methods of objects in dependencies are returning nil, or throwing errors as if the function doesn't exist. Copy the class back to the current project, and everything is fine. Move it out to the library, and suddenly some (but not all) methods of the class seem to throw errors. Oddly enough, the attributes of the object are fine.

    Trying to make a neat example, but the only place it's popping up is a large project with a total of 46 tabs (which don't redefine the classes in question or have references to yet more libraries -- I checked)

  • Posts: 1,255

    location.available() isn't reliable. It will often return false even when called after location.enable() and when location readings are working fine.

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @Mark hmm, this is what we are actually checking for on the available() call:

    abailable = ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized &&
            [CLLocationManager locationServicesEnabled])
    

    We should probably also check for kCLAuthorizationStatusAuthorizedWhenInUse which is new in iOS 8. I will fix this in 2.2.

  • edited December 2014 Posts: 1,255

    @Simeon Here's another fun one. I have code on one iPad running 2.2. (1). This code runs fine. The code includes a large project and two libraries. All good.

    However, I copied each project to text and emailed them to the second iPad then restored the libraries and projects using Paste Into Project. This iPad is running 2.1 (24). The code will not run. It's throwing errors on functions of parent classes. For added fun, the properties of these same classes still hold the correct values.

    As an example, the Frame class has Frame.init(x, y, w, h) and a Frame:right() which returns x + w.

    The SettingsBox(Frame) class is defined with SettingsBox.init(x, y, w, h) and with the first line of the init being Frame.(self, x, y, w, h)

    If I define s = SettingsBox(10, 10, 100, 100) I can still reference s.x and get 10. But if I call s:right() on the iPad running 2.2(1) I get 110, while on the iPad running 2.1(24) I get nil.

    Since I did a copy paste to get onto the 2.1(24) iPad, I've looked for the obvious things -- tab order, or any visible extra/missing characters. So far as what is visible to me, both are identical.

    It seems to be some kind of dependency tangle. Project 1 uses library 1 and library 2. Library 1 also uses library 2.

    One the first iPad, everyone is happy. On the second iPad, Library 1 throws an error when I run Project 1... making me suspect it's "compiling" before library 2... but there seems to be no way to change the dependency order.

    Does any of that make sense?

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @Mark the dependency order is stored in the info.plist within the project (as an array, I think). Perhaps you could try swap the order and see if that resolves the issue?

  • edited December 2014 Posts: 2,043

    @Simeon, have you had a chance to look into the runtime physics bug I mentioned? It's all that's keeping me from releasing my game.

    It seems to happen when the following conditions are met:

    • having the gamecenter addon enabled

    • having the collide function somewhere in your code

    • applied force to a body

    • that body collides with another body

    Here is some example code that causes the problem:

    function setup()
        ball = physics.body(CIRCLE, WIDTH / 20)
        ball.x, ball.y = WIDTH / 2, HEIGHT / 2
    
        wall = physics.body(EDGE, vec2(WIDTH, 0), vec2(0, 0))
    
        ball:applyForce(vec2(100, 100))
    end
    
    function draw()
        background(255)
    
        ellipse(ball.x, ball.y, ball.radius * 2)
    end
    
    function collide(c)
    
    end
    

    If you paste that into main and enable the gamecenter addon, the error should come up

    Thanks!

    EDIT: Logged on the Issue Tracker for you

  • edited December 2014 Posts: 2,043

    Going a bit further, I tracked it to this line:

    luaL_openlib(L, GAMECENTER_LIB_NAME, gamecenterLibs, 0);

    I'm not sure why that line (in conjuction with all the conditions above) causes a problem, but to fix it I replaced it with these:

     lua_register(L, "gamecenter_enabled", gamecenter_enabled);
     lua_register(L, "gamecenter_showLeaderboards", gamecenter_showLeaderboards);
     lua_register(L, "gamecenter_showAchievements", gamecenter_showAchievements);
     lua_register(L, "gamecenter_submitScore", gamecenter_submitScore);
     lua_register(L, "gamecenter_submitAchievement", gamecenter_submitAchievement);
    

    which changes the lua API a bit but not much

    Not sure what the problem was, or how great my solution is, but it seems to work so far.

    EDIT:

    Another issue: the way you were getting the numbers from Lua was not getting them correctly. Replace code like this lua_Number percent = luaL_checknumber(L, 2); with this double percent = atof(lua_tostring(L, 2)); and it should work correctly.

  • SimeonSimeon Admin Mod
    Posts: 5,412

    Thanks for the detective work @JakAttak. I suspect something funny is happening to the Lua stack in the physics code. I will debug.

    Odd that it wasn't getting numbers correctly, what was luaL_checknumber doing to the numbers?

  • Posts: 2,043

    @Simeon, most of them came out as 0 or as something enormous like 218361376736.1972393898.

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @JakAttak very strange. On both the simulator and device? Is this through looking with the debugger?

  • Posts: 2,043

    @Simeon, yes both on device and simulator. I did a print in lua and an NSLog in C of the value to figure this out, the print returned the correct value, the NSLog returned the wacky one

  • Posts: 2,820

    Sorry, I can't really check out the beta, since I'm renting out my iPad to people, but if I get a chance before release, I'll be sure to test it out. Thanks!

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @JakAttak can you give me a very simple example e.g., using the existing game center addon or something like that, which prints out a bad value in C?

  • Posts: 2,043

    @Simeon, in the submitAchievements function, percent will print out a bad value in C

  • IgnatzIgnatz Mod
    Posts: 5,396

    @Simeon - apparently, this code used to work in previous versions

    S = shader([[ //vertex code]], [[ //fragment code]])
    m.shader = S
    

    Now it throws a shader compilation error, seemingly because Codea doesn't like shader objects that are independent of a mesh.

    It can be fixed by rewriting S as a table of strings, and then assigning a shader to the mesh, using those strings - which has been the usual way to embed shaders in code.

    S = {v=[[ //vertex code]], f=[[ //fragment code]]}
    m.shader = shader(S.v, S.f)
    

    See this thread for actual code examples

    http://codea.io/talk/discussion/6034/shader-compile-error

  • SimeonSimeon Admin Mod
    Posts: 5,412

    Thank you @Ignatz

    It depends where the shader is constructed. If it happens in the global scope, then there will be a shader compile error because there is no GL context setup at that time.

    We should defer the actual shader compilation until later, but at the moment the best fix is to construct your shaders in setup() and not out in the global scope.

    e.g.,


    function setupShaders() myShader = shader("void main(){}", "void main(){}") end function setup() setupShaders() end -- If setupShaders is called out here, there will be a compile error setupShaders()
  • Posts: 505

    Ah, thanks for the debugging of the shader issue! :)

  • Posts: 2,043

    For the first time ever in my use of Air Code, it just crashed and deleted half my tabs. I checked iExplorer, the files are completely gone. (Luckily I was just monkeying around with a project I have already exported)

    This may not be a 2.2 issue, but it has never happened to me before.

    Using iOS 8 on an iPad Mini, OS X Yosemite on a Mac Mini, and Chrome browser.

  • Posts: 1,976

    Before you submit 2.2, I've been forgetting to report a few bugs/weird things:

    1. My Codea's app images seem to have disappeared - the pause button is invisible, I can't change the editor background, and it doesn't seem to be saving my settings (font size keeps resetting itself) (note, I am low on space)

    2. Pressing the documentation or search buttons on your keyboard in the editor twice really quickly can cause a black panel to be stuck on the left side of the screen, and goes away when you show/hide the documentation or search again.

    3. If you were in landscape mode in the editor, then run an app that forces your iPad into portrait mode and shows the keyboard, when you go back into the editor, the keyboard is sideway (changing your orientation manually fixes it)

    4. The shader lab has been inconsistent for me with saving, and I find myself saving my shader code to the Notes app just in case - occasionally, when I leave the shader lab and come back to my shader, it has been reset to the default shader, like it didn't save anything.

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @SkyTheCoder it sounds like 1 & 4 might be symptoms of low disk space. I'll have to think about how to handle that. I will look into the other two as well, if you have time I'd appreciate if you could log them on the issue tracker.

  • edited January 2015 Posts: 1,976

    @Simeon Issue #1 started occurring when I had over 100 MB of space available.

  • Jmv38Jmv38 Mod
    edited January 2015 Posts: 3,297

    Couple bugs:
    - saving the project icon from the interface button doesnt work on my project. [EDIT] happens only when project:icon is already defined. I had to manually delete the project:icon image to get it work. When saved from button, it should overwrite project:icon, shouldnt it?
    - copying text to clipboard (a long project i suppose) crashes codea.
    - from project panel: show content left panel, the project panel background disappears, and remains gone when i close left panel.

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @SkyTheCoder the project browser background in particular is stored in Library/Caches, so when iOS "cleans" apps when it runs low of disk space it kills this folder. This also includes pre-rendered UI assets (like the pause button). My guess is iOS cleans out the assets folder but doesn't kill the app, so it doesn't get a chance to re-render the UI elements and other assets. Did the pause button eventually come back?

  • Posts: 1,976

    @Simeon The pause button came back, but I still can't change my background. Also, is it just me, or does the pause button occasionally freeze up the entire app, not letting you even unpause?

  • Posts: 2,820

    @Simeon - I don't have an iPad anymore, so I can't really test Codea anymore. Feel free to remove me from your beta testing lists. Thanks, and good luck with Codea and your other endeavors (especially Crabitron, looks promising)!

  • SimeonSimeon Admin Mod
    Posts: 5,412

    @Zoyt no problem

    @everyone I'm moving over to Apple's TestFlight service for future builds — the old TestFlight service is shutting down on 26 February, so this is a forced requirement.

    The only issue is that you will need iOS 8 to use the new TestFlight app. Other than that, the service seems better.

  • SimeonSimeon Admin Mod
    Posts: 5,412

    Just a post to direct new beta testers to this thread. You can use the "beta" category to ensure your beta-related posts are only seen by other beta testers.

Sign In or Register to comment.