Plugin to record voice?

I wrote it on a Mac, so no problem there. I just don't have a smart phone or also a Linux computer to test on.

I'm not sure, but I don't think node works in browsers and the phone app is like a browser.
I wrote it on a Mac, so no problem there. I just don't have a smart phone or also a Linux computer to test on.

I'm not sure, but I don't think node works in browsers and the phone app is like a browser.

I see... never mind... I'll have to focus on computers.

Please let me know when you have the camera plugin, I really want to take a look at it working on the maker 🙂

I was thinking that the game could take a screenshot when showing the waves of the player and then show both images. This could serve as a "Customized flashback" too, for example taking a screenshot in a particular moment and show that image later on the game as a memory (Maybe in a final credit scene?) Anyway... I have lot of ideas on my mind haha... I don´t know if it`s possible... I'll have to look for it.
The plugin is ready, but I should really fix the path flaw before a moderator checks it and makes the thread live. It had the same path thing as this.

Start a request thread for a screenshot plugin. Somebody might already have one. Screenshots should be easier than this audio thing.

Though, it's another one of those things that if the pngs need saved, it won't work in browsers. Come to think of it, I don't think you can save games in browsers without a server side plugin.

If you want to host this game, I could make a PHP plugin to make it save the audio/photos in the game and then it might also work on phones too, if you are going to host it online. Though I think online plugins need to go in another forum because they don't use 100% javascript.
The plugin is ready, but I should really fix the path flaw before a moderator checks it and makes the thread live. It had the same path thing as this.

Start a request thread for a screenshot plugin. Somebody might already have one. Screenshots should be easier than this audio thing.

Though, it's another one of those things that if the pngs need saved, it won't work in browsers. Come to think of it, I don't think you can save games in browsers without a server side plugin.

If you want to host this game, I could make a PHP plugin to make it save the audio/photos in the game and then it might also work on phones too, if you are going to host it online. Though I think online plugins need to go in another forum because they don't use 100% javascript.

Thanks for the advice! And yes, I'd really like to host the game when is ready! I'll start another thread then. Actually I have one about showing two different dialogues at the same time, but I have not had help yet 🙁

Oh, and when I said "the other things" I was talking about comparing the two waves, sorry, sometimes it`s really hard trying to express myself properly in English.

Anyway... I don`t want to abuse, and you have been very kind, dude, I really appreciate it!
We might be getting a little off topic here, but I made a quick save screenshots plugin.

Spoiler
Screen%20Shot%202017-04-23%20at%2011.22.01%20PM.png

PHP:
var screenShotSaveByNodeFs = function(filename){
   var fs = require('fs');
   var path = require('path');
   var lp = document.location.pathname;
   var pathName = lp.match(/^\/?\w:\//)!==null? // windows path
       decodeURIComponent(lp.replace(/^\/|index\.html$/g, ''))
   :
       decodeURIComponent(lp.replace(/index\.html$/, '')); // mac path
   fs.writeFile(path.join(path.normalize(pathName + "img/pictures/"), path.normalize(filename)),
       SceneManager.snap()._canvas.toDataURL("image/png").split(",")[1], 'base64',
       function(er) {
           if (er) alert(er);
       }
   );
};

Call it by event script like this. The parameter/argument is the filename to save as.
PHP:
screenShotSaveByNodeFs("screenshot_"+(new Date).getTime()+".png");

It can be like "picture123.png". I just added the getTime so no photo is ever overwritten.
We might be getting a little off topic here, but I made a quick save screenshots plugin.

Spoiler
Screen%20Shot%202017-04-23%20at%2011.22.01%20PM.png

PHP:
var screenShotSaveByNodeFs = function(filename){
   var fs = require('fs');
   var path = require('path');
   var lp = document.location.pathname;
   var pathName = lp.match(/^\/?\w:\//)!==null? // windows path
       decodeURIComponent(lp.replace(/^\/|index\.html$/g, ''))
   :
       decodeURIComponent(lp.replace(/index\.html$/, '')); // mac path
   fs.writeFile(path.join(path.normalize(pathName + "img/pictures/"), path.normalize(filename)),
       SceneManager.snap()._canvas.toDataURL("image/png").split(",")[1], 'base64',
       function(er) {
           if (er) alert(er);
       }
   );
};

Call it by event script like this. The parameter/argument is the filename to save as.
PHP:
screenShotSaveByNodeFs("screenshot_"+(new Date).getTime()+".png");

It can be like "picture123.png". I just added the getTime so no photo is ever overwritten.


Wow you're amazing, dude! When I get home, I'll try it!

However, I realized last night that I'm getting a random error with the recording of the voice:

64d4cd09-124a-4f2b-8f08-ad4e324e472b
djrsH5s.png


I don`t have any idea about this. Sometimes this error appears and sometimes not. It`s totally random.

Can you check it, please?
Random errors, or Heisenbugs, are the worst kind.

Consistency helps me pin point it. I hate looking at the part that works most of the time and trying to guess what's going wrong. Especially when I merely implemented this script for MV and I only wrote about 10%...

Ayeyeye!
I've been playing around with it, and I've even been getting a different random error, actually. So now I've got two errors.
Screen Shot 2017-04-24 at 8.46.17 AM.png


It will come to me I'm sure...


EDIT: The only alias is Game_Message.prototype.clear, which might be firing early on too many key presses.
I was able to resolve my random error AudioContext message. I hope this covers your random problem too, like if the message is only different because Windows/Mac.

Version 0.4
The plugin will work fine in the MV engine with nodeJS, but if you try to run the project on the web, or on a phone -- it won't work. A computer should be fine though.
I was able to resolve my random error AudioContext message. I hope this covers your random problem too, like the message is only different because Windows/Mac.

Version 0.4

Ok I tested a lot this new version and the plugin still fails with this error:

lLF3aLb.png


But this is not random anymore, it seems the plugin fails when I try to record more than 5 seconds. If I record less than that, then works perfectly.

Can you try adding some kind of 5 seconds countdown? Anyway, 5 seconds are enough, (at least for me). Can you check this, please?
I just made a 30 second recording. I just read that the limit on FileReader is 261 MB, so I don't think 5 seconds of ogg will matter.

I know I've probably did something sloppy in my tiny part of the script.
EDIT:
Before I limit the recording, I've just made a big fix. I realized from using Microsnitch that the microphone was left on recording. I just needed to run .stop() on the stream and Microsnitch says the camera/microphone becomes inactive.

Screen%20Shot%202017-04-24%20at%202.46.52%20PM.png


Version 0.5 - (I've never scripted audio stuff before)
I just made a 30 second recording. I just read that the limit on FileReader is 261 MB, so I don't think 5 seconds of ogg will matter.

I know I've probably did something sloppy in my tiny part of the script.
EDIT:
Before I limit the recording, I've just made a big fix. I realized from using Microsnitch that the microphone was left on recording. I just needed to run .stop() on the stream and Microsnitch says the camera/microphone becomes inactive.

Screen%20Shot%202017-04-24%20at%202.46.52%20PM.png


Version 0.5 - (I've never scripted audio stuff before)


I`m still having the same issue, dude 🙁

LQ2NHO2.png


But I can´t see the hat and headphones of your image. Did you post the right .js?
Get version 0.5 posted above. I don't see a download count.
Get version 0.5 posted above. I don't see a download count.

Oh my mistake haha. Now works perfectly!

So the last... is it possible to add some customizable countdown for the record? The last thing I ask you on this topic dude... you`re amazing!

EDIT: Oh, by the way... your screenshot plugin works perfectly! Thank you so much! I have just one question, how can I change the numbers in the name of the file? (For example, I would like files as "Image1", "Image2", and so on...)
Vanilla, you can just set the filename to "picture1.png"
like so...
PHP:
screenShotSaveByNodeFs("scenePicture1.png");
PHP:
screenShotSaveByNodeFs("scenePicture2.png");

Or if you are using the same event more than once, I can teach you how concat a window variable.
PHP:
window.myPic = window.myPic || 0;
window.myPic++; // becomes 1, 2, 3, 4, etc...
screenShotSaveByNodeFs("scenePicture"+window.myPic+".png");

fiveseco.gif

By the way, I added 5 second timer like you wanted if you are still interested in limiting the recording.

version 0.6 (now with 5 second recording limit)
Vanilla, you can just set the filename to "picture1.png"
like so...
PHP:
screenShotSaveByNodeFs("scenePicture1.png");
PHP:
screenShotSaveByNodeFs("scenePicture2.png");

Or if you are using the same event more than once, I can teach you how concat a window variable.
PHP:
window.myPic = window.myPic || 0;
window.myPic++; // becomes 1, 2, 3, 4, etc...
screenShotSaveByNodeFs("scenePicture"+window.myPic+".png");

fiveseco.gif

By the way, I added 5 second timer like you wanted if you are still interested in limiting the recording.

version 0.6 (now with 5 second recording limit)

WOW this works perfectly and its exactly what I needed! Thank you so much dude, I owe you a big one! 🙂
You owe the recorder.js library from Github. The one small part I wrote was crashing all the way.
You owe the recorder.js library from Github. The one small part I wrote was crashing all the way.

Now you mention it... I realized the plugin still crash... not so much as before, at least :/

YLDdl9V.png


Is there a way to lock the 5 seconds recording? I mean, that the player couln`t skip the recording before those 5 seconds. I think that would fix the problem, and would be very useful for what I have in mind!
I've tried replicating that error and I cannot.

I think it's caused by recorder.js exportWAV being called more than once, and the latter time the blob is undefined, so I've added a line to return if the blob is not a blob. The error may still occur, but it shouldn't crash anymore.

I also made the FileReader a global, because something tells me it stops creating readers after so many blobs.

This should fix the problem. (Hopefully 😍)

Version 0.7
I've tried replicating that error and I cannot.

I think it's caused by recorder.js exportWAV being called more than once, and the latter time the blob is undefined, so I've added a line to return if the blob is not a blob. The error may still occur, but it shouldn't crash anymore.

I also made the FileReader a global, because something tells me it stops creating readers after so many blobs.

This should fix the problem. (Hopefully 😍)

Version 0.7

You DID it!

I tested this new version all morning and no errors anymore! 🙂 You`re the best! 😀

Original thread: https://forums.rpgmakerweb.com/threads/plugin-to-record-voice.77683/