Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Sound Volume — Gideros Forum

Sound Volume

misterhupmisterhup Member
edited March 2016 in General questions
Can Gideros use a microphone plugin and record a sound then detect it's volume and use it? I know there is a plugin for the microphone, but I don't really know how to use it yet, and I want to know first what it can do before diving into it. :)

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    I honestly don't remember :)

    But microphone plugin should be available out of the box with Gideros desktop player (plugin already installed with latest release)

    and docs are here:
    http://docs.giderosmobile.com/reference/plugin/Microphone#Microphone

    and from there is seem yes, you create Microphone instance, and listen to event and event shows amplitude, if microphone hears anything and then you can start to record sounds.

    Likes: misterhup

    +1 -1 (+1 / -0 )Share on Facebook
  • misterhupmisterhup Member
    edited March 2016
    @ar2rsawseen I can't figure this out :-(( Is it even possible to constantly record while the app is running and print the volume every couple of milliseconds? If so, can you give an example? [-O< [-O< [-O<
  • ar2rsawseenar2rsawseen Maintainer
    edited March 2016
    well, you can try, it would look something like this:
    require("microphone")
     
    --create microphone instance with default values
    local mic = Microphone.new(nil, 4000, 1, 8)
     
    --set where the file will be stored
    mic:setOutputFile("|D|test.wav")
     
    --set up and event and print out the values
    mic:addEventListener(Event.DATA_AVAILABLE, function(e)
        print(e.peakAmplitute, e.averageAmplitute)
    end)
     
    --start recording
    mic:start()
     
    --yell in the mic and see if there is anything printing out
     
    --and after some time or on some event, drop the mic <img class="emoji" src="https://forum.giderosmobile.com/resources/emoji/smile.png" title=":)" alt=":)" height="20" />
    Timer.delayedCall(1000, function()
        mic:stop()
    end)

    Likes: rolfpancake

    +1 -1 (+1 / -0 )Share on Facebook
  • misterhupmisterhup Member
    edited March 2016
    main.lua:2: attempt to index global 'Microphone' (a nil value)
    The same error I got yesterday when I tried to play with this plugin... I checked the plugin folder, everything is there and I'm running the latest gideros version on Windows... Please tell me I am doing something wrong...
  • ar2rsawseenar2rsawseen Maintainer
    ahh, sorry, forgot
    require("microphone")
    :)
  • misterhupmisterhup Member
    edited March 2016
    @ar2rsawseen It works on PC but I get this error when I try to run the app on the phone:
    Uploading finished.
    main.lua:2: module 'microphone' not found:
    	no field package.preload['microphone']
    	no file './microphone.lua'
    	no file '/usr/local/share/lua/5.1/microphone.lua'
    	no file '/usr/local/share/lua/5.1/microphone/init.lua'
    	no file '/usr/local/lib/lua/5.1/microphone.lua'
    	no file '/usr/local/lib/lua/5.1/microphone/init.lua'
    	no file './microphone.so'
    	no file '/usr/local/lib/lua/5.1/microphone.so'
    	no file '/usr/local/lib/lua/5.1/loadall.so'
    stack traceback:
    	main.lua:2: in main chunk
  • ar2rsawseenar2rsawseen Maintainer
    Yes, as per docs you need to add microphone plugin.
    Plugin files should be in Gideros installation/All Plugins/Microphone/Android
    So export your app and modify Android project:

    Copy bin/Android/* to libs directory.
    Copy source/com/* to your project.
    Add System.loadLibrary("microphone"); to your main Activity.
    Add "com.giderosmobile.android.plugins.GMicrophone" to externalClasses array.
    Add android.permission.RECORD_AUDIO permission to your AndroidManifest.

    Likes: rolfpancake

    +1 -1 (+1 / -0 )Share on Facebook
  • So I went back to work on this project and I did everything as instructed, but it does not work. And also I do not get any errors. I'm pretty sure I mess something up with the folders. Here is where I get confused at. I go to Gideros installation/All Plugins/Microphone/ but there is no Android folder in there, just bin and source. The bin folder contains an "Android" folder which then contains a "libs" and a "src" folder... Do I copy both to libs directory in my project overlapping the existing ones? :-/
  • @ar2rsawseen Can you give me some step by step instructions on which folders to copy and where to paste them more exactly? (because I get confused at the first 2 instructions you gave me, but did everything else right,I suppose). I apologize because this is such a dumb question on my side, but after I get this answer I wont bother anyone a while :))
    Please answer as soon as possible, I really need to fix this issue asap. Thank you!
  • ar2rsawseenar2rsawseen Maintainer
    yes, bin folder, sorry so

    Copy bin/Android/libs/* to libs directory.
    Copy bin/Android/src/* to src directory.

    That is for eclipse though. I always forget about Android Studio, as I'm not using it :)
  • ar2rsawseenar2rsawseen Maintainer
    Ok based on this post I posted long time ago, for Android Studio it should be:
    http://giderosmobile.com/forum/discussion/comment/43090#Comment_43090

    Copy bin/Android/libs/* to app\src\main\jniLibs directory.
    Copy bin/Android/src/* to app\src\main\java directory.
  • piepie Member
    @misterhup did you manage to get microphone plugin working on Android?
    I did as @ar2rsawseen said, and even if I don't get any error from eclipse, my device is not able to use its microphone. :(

    thank you
  • ar2rsawseenar2rsawseen Maintainer
    I think you also need a permission in Android manifest

    android.permission.RECORD_AUDIO
  • hgy29hgy29 Maintainer
    microphone plugin would be a good first candidate for automatic integration during export :)
  • piepie Member
    @ar2rsawseen I have it in my manifest as:
    <uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
    @hgy29 I'm looking forward to automatic plugin integration... :D


    thank you :)
Sign In or Register to comment.