#import "PluginMicrophonePower.h" #include \<CoronaRuntime.h\> #import \<UIKit/UIKit.h\> // ---------------------------------------------------------------------------- class microphonePower { public: typedef microphonePower Self; public: static const char kName[]; static const char kEvent[]; protected: microphonePower(); public: bool Initialize( CoronaLuaRef listener ); public: CoronaLuaRef GetListener() const { return fListener; } public: static int Open( lua\_State \*L ); protected: static int Finalizer( lua\_State \*L ); public: static Self \*ToLibrary( lua\_State \*L ); public: static int init( lua\_State \*L ); static int getPower( lua\_State \*L ); static int startRecording( lua\_State \*L ); static int stopRecording( lua\_State \*L ); static int startSession( lua\_State \*L ); private: CoronaLuaRef fListener; }; // ---------------------------------------------------------------------------- // This corresponds to the name of the library, e.g. [Lua] require "plugin.library" const char microphonePower::kName[] = "plugin.microphonePower"; // This corresponds to the event name, e.g. [Lua] event.name const char microphonePower::kEvent[] = "power"; FrequencyCheck \*frequecyCheck; microphonePower::microphonePower() : fListener( NULL ) { } bool microphonePower::Initialize( CoronaLuaRef listener ) { // Can only initialize listener once bool result = ( NULL == fListener ); if ( result ) { fListener = listener; } return result; } int microphonePower::Open( lua\_State \*L ) { // Register \_\_gc callback const char kMetatableName[] = \_\_FILE\_\_; // Globally unique string to prevent collision CoronaLuaInitializeGCMetatable( L, kMetatableName, Finalizer ); // Functions in library const luaL\_Reg kVTable[] = { { "init", init }, { "getPower", getPower }, { "startRecording", startRecording }, { "stopRecording", stopRecording }, { "startSession", startSession }, { NULL, NULL } }; // Set library as upvalue for each library function Self \*library = new Self; CoronaLuaPushUserdata( L, library, kMetatableName ); luaL\_openlib( L, kName, kVTable, 1 ); // leave "library" on top of stack return 1; } int microphonePower::Finalizer( lua\_State \*L ) { Self \*library = (Self \*)CoronaLuaToUserdata( L, 1 ); CoronaLuaDeleteRef( L, library-\>GetListener() ); delete library; return 0; } microphonePower \* microphonePower::ToLibrary( lua\_State \*L ) { // library is pushed as part of the closure Self \*library = (Self \*)CoronaLuaToUserdata( L, lua\_upvalueindex( 1 ) ); return library; } int microphonePower::init( lua\_State \*L ) { frequecyCheck = [[FrequencyCheck alloc] init]; const char \*word = lua\_tostring(L, 1); NSString \*filename = [NSString stringWithUTF8String:word]; [frequecyCheck createRecorder:filename]; int listenerIndex = 2; if ( CoronaLuaIsListener( L, listenerIndex, kEvent ) ) { Self \*library = ToLibrary( L ); CoronaLuaRef listener = CoronaLuaNewRef( L, listenerIndex ); library-\>Initialize( listener ); } return 0; } // [Lua] library.show( word ) int microphonePower::getPower( lua\_State \*L ) { // NSLog(@"Mic blow detected, %f", [frequecyCheck checkFrequency]); double frequencyValue = [frequecyCheck checkFrequency]\*100; Self \*library = ToLibrary( L ); // Create event and add message to it CoronaLuaNewEvent( L, kEvent ); lua\_pushnumber( L, frequencyValue ); lua\_setfield( L, -2, "value" ); // Dispatch event to library's listener CoronaLuaDispatchEvent( L, library-\>GetListener(), 0 ); return 0; } int microphonePower::startRecording( lua\_State \*L ) { [frequecyCheck startRecording]; return 0; } int microphonePower::stopRecording( lua\_State \*L ) { [frequecyCheck stopRecording]; return 0; } int microphonePower::startSession( lua\_State \*L ) { [frequecyCheck startSession]; return 0; } // ---------------------------------------------------------------------------- CORONA\_EXPORT int luaopen\_plugin\_microphonePower( lua\_State \*L ) { return microphonePower::Open( L ); }
Here is my ‘PluginMicrophonePower.mm’ but i think issue is not within this issue. Issue is in ‘.a’ maybe when i am making ‘.a’ i am missing something. How can i detect my issue with ‘.a’ file. Can i see into my ‘.a’ file?