It looks like you're new here. If you want to get involved, click one of these buttons!
require "microphone" Options = gideros.class(Sprite) -- options local width = application:getContentWidth() local height = application:getContentHeight() local dx = application:getLogicalTranslateX() / application:getLogicalScaleX() local dy = application:getLogicalTranslateY() / application:getLogicalScaleY() function Options:init() self.levelMeter = LevelMeter.new() self:addChild(self.levelMeter) self.levelMeter:setY(30) self.microphone = Microphone.new(nil, 22050, 1, 16) self.microphone:addEventListener(Event.DATA_AVAILABLE, function(event) print("*") self.levelMeter:setLevel(event.peakAmplitude, self) end) self.microphone:setOutputFile("|D|record.wav") self.record = Button.new( Bitmap.new(Texture.new("gfx/record-up.png")), Bitmap.new(Texture.new("gfx/record-down.png")), Bitmap.new(Texture.new("gfx/record-disabled.png"))) self.record:setPosition(70, 130) self:addChild(self.record) self.recordStop = Button.new( Bitmap.new(Texture.new("gfx/stop-up.png")), Bitmap.new(Texture.new("gfx/stop-down.png"))) self.recordStop:setPosition(70, 130) self.play = Button.new( Bitmap.new(Texture.new("gfx/play-up.png")), Bitmap.new(Texture.new("gfx/play-down.png")), Bitmap.new(Texture.new("gfx/play-disabled.png"))) self.play:setPosition(70, 200) self.play:setDisabled(true) self:addChild(self.play) self.playStop = Button.new(Bitmap.new(Texture.new("gfx/stop-up.png")), Bitmap.new(Texture.new("gfx/stop-down.png"))) self.playStop:setPosition(70, 200) function self:onRecord() self.play:setDisabled(true) self.record:removeFromParent() self:addChild(self.recordStop) self.microphone:start() end self.record:addEventListener(Event.CLICK, self.onRecord, self) function self:onRecordStop() self.play:setDisabled(false) self.recordStop:removeFromParent() self:addChild(self.record) self.microphone:stop() self.levelMeter:setLevel(0) self.play:setDisabled(false) end self.recordStop:addEventListener(Event.CLICK, self.onRecordStop, self) local sound = nil local channel = nil function self:onPlayStop() self.record:setDisabled(false) self.playStop:removeFromParent() self:addChild(self.play) self.channel:stop() end self.playStop:addEventListener(Event.CLICK, self.onPlayStop, self) function self:onPlay() self.record:setDisabled(true) self.play:removeFromParent() self:addChild(self.playStop) self.sound = Sound.new("|D|record.wav") self.channel = self.sound:play() self.channel:addEventListener(Event.COMPLETE, self.onPlayStop, self) end self.play:addEventListener(Event.CLICK, self.onPlay, self) self.background = Bitmap.new(TextureRegion.new(Texture.new("gfx/mainlandscape.png", true))) self:addChild(self.background) --set position in center self.background:setAnchorPoint(0.5, 0.5) self.background:setPosition(width/2, height/2) local texture = Texture.new("gfx/home.png") local back = Bitmap.new(texture) back:setScale(1) self.back = Button.new(back, back) self.back:setPosition((width-self.back:getWidth())/2, 40) self:addChild(self.back) self.back:addEventListener("click", function() sc.scenes:changeScene("StartPage",1, SceneManager.fade, moveFromRightWithFade) end) end |
Comments
PMed you
Ha, ha! )
Still, would you mind posting a brief summary of the solution here for all to see?
Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.
I just took the project of @mysps I had previously, and added the code from mic example project.
Did not post here, because it is a private @mysps project, so send through pm and let @mysps figure out what was wrong
Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.
thanks!
Questions:
Why isn't the function Microphone not added to self?
Thanks again Arturs and Happy Birthday!!
Thanks, @mysps.
Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.