NMessageVoice.js
by Nomid
Descrizione
Questo plugin vi consentirà di impostare una voce per i vostri messaggi di dialogo.
Autore
Nomid
...ovvero io u.u
Allegati
voice_good.zip 9.39K 25 Numero di downloads
Istruzioni
--- Prerequisiti
Per prima cosa, è necessario che sia presente almeno un suono per la voce, da mettere nella cartella SE nei due formati m4a e ogg.
Per comodità, vi allego un suono creato da me da usare come voce, già convertito.
--- Configurazione
Usare il mio plugin è molto semplice e necessita di poche impostazioni di base.
Innanzitutto notiamo che la descrizione dice che ogni lettera avrà il suo suono, quindi il file audio verrà suonato per ogni lettera del dialogo, motivo per cui è probabile che i suoni si accavallino.
Per evitare questo fastidioso effetto sarebbe comodo avere un audio che duri poco come quello che vi ho allegato, oppure potete provare impostando Use Static Sound su true.
Passiamo ora nello specifico:
- Default Voice
Default: voice_default
Questo parametro contiene il nome del file senza estensione del suono SE da utilizzare come voce di default, cioè quando non viene specificata alcuna voce per il dialogo.
Nel nostro caso possiamo usare voice_good come valore.
- Has Voice By Default
Default: true
Quando questo parametro è impostato su true tutti i dialoghi avranno una voce (se non specificata verrà usata quella di default), altrimenti, impostare il parametro su false.
- Voice Volume
Default: 80
Questo valore imposta il volume del suono della voce, che deve essere compreso tra 0 e 100.
- Use Static Sound
Default: false
Questo parametro indica se si deve utilizzare il metodo static per suonare la voce.
Se impostato su true allora i suoni non verranno accavallati, altrimenti impostare false.
- Fixed Voice Pitch
Default: false
Se impostato su true le voci avranno un tono fisso (che sarà 100 di default, ma si può modificare con il comando NMsgVoice.setPitch) e non randomico (compreso tra i valori di Voice Pitches che possono essere modificati col comando NMsgVoice.setPitches).
- Voice Pitches
Default: 70 100 150
Questo parametro indica una lista di valori possibili separati da spazi per il tono randomico della voce.
I valori devono essere compresi tra 0 e 200.
Questa impostazione verrà ignorata se Fixed Voice Pitch è impostato su true.
Se i valori delle impostazioni dovessero risultare erronei, un NMessageVoiceException verrà mostrato come errore.
In tal caso, un try-catch dovrebbe funzionare.
--- Comandi plugin
Per avere più controllo sulla voce, metto a disposizione alcune imposazioni istantanee per i messaggi di dialogo.
Questi comandi vanno eseguiti prima del dialogo di riferimento e hanno effetto solo su quel medesimo dialogo, mentre sui successivi varranno le impostazioni del plugin se nessun altro comando le modifica.
Per comodità e per evitare conflitti con altri plugin, ogni comando ha il prefisso NMsgVoice:
- NMsgVoice.setName
Questo comando imposta il nome del file della voce da utilizzare per il dialogo successivo.
Uso:NMsgVoice.setName voice_good
- NMsgVoice.setVolume
Questo comando imposta il volume della voce per il dialogo successivo.
Il valore è numerico e deve essere compreso tra 0 e 100.
Uso:NMsgVoice.setVolume 80
- NMsgVoice.setPan
Questo comando imposta la direzione dalla quale proviene la voce per il dialogo successivo.
Il valore è numerico e deve essere compreso tra -100 e 100.
Il che significa che se il valore è -100, il suono proverrà dall'estrema sinistra.
Uso:NMsgVoice.setPan -100
- NMsgVoice.setPitch
Questo comando imposta il tono della voce per il dialogo successivo.
Il valore è numerico e deve essere compreso tra 0 e 200.
Viene ignorato se Fixed Voice Pitch è impostato su false.
Uso:NMsgVoice.setPitch 100
- NMsgVoice.setPitches
Quando Fixed Voice Pitch è false, questo comando imposta i toni che può randomicamente assumere la voce del dialogo successivo.
I valori sono numerici, separati da spazi e devono essere compresi tra 0 e 200.
Uso:NMsgVoice.setPitches 70 100 150
- NMsgVoice.useFixedPitch
Questo comando modifica il parametro Fixed Voice Pitch del plugin per il dialogo successivo.
Può essere true oppure false.
Uso:NMsgVoice.useFixedPitch true
- NMsgVoice.useStatic
Questo comando modifica il parametro Use Static Sound del plugin per il dialogo successivo.
Può essere true oppure false.
Uso:NMsgVoice.useStatic true
- NMsgVoice.useDefault
Questo comando imposta la voce di default per il dialogo successivo.
Non ha parametri.
Uso:NMsgVoice.useDefault
- NMsgVoice.hasVoiceByDefault
Questo comando modifica il parametro Has Voice By Default del plugin per il dialogo successivo.
Può essere true oppure false.
Uso:NMsgVoice.hasVoiceByDefault false
Se i valori delle impostazioni dovessero risultare erronei, un NMessageVoiceException verrà mostrato come errore.
In tal caso, un try-catch dovrebbe funzionare.
--- enjoy u.u
Script
//============================================================================= // NMessageVoice.js //============================================================================= /*: * @plugindesc Every letter in the dialogs has a voice. * @author Nomid * * @param Default Voice * @desc The sound to be played by default. * @default voice_default * * @param Has Voice By Default * @desc Whether or not the messages have a voice by default. * @default true * * @param Voice Volume * @desc Volume of the voice sound between 0 and 100. * @default 80 * * @param Use Static Sound * @desc If true, every instance of the sound will be stopped to play another one (can be useful for long sounds). * @default false * * @param Fixed Voice Pitch * @desc If true, all the messages will use a fixed pitch instead of a random one and the pitch will be set to 100 as default. * @default false * * @param Voice Pitches * @desc A list of possible pitches for the voice. * @default 70 100 150 * * @help * --- Prerequisites * First, you need at least one sound to use as a voice, to be placed in the SE folder as both m4a and ogg. * * --- Configuration * Using my plugin is really simple and requires just a few settings. * * First of all, every letter will have its sound, so they might overlap. * To avoid this effect you can shorten the audio length or try setting Use Static Sound on true. * * Let's now go to the technical specifications: * * --- Plugin Settings * > Default Voice * Default: voice_default * This contains the name of the SE sound to be used as default voice when no voice has been specified. * * > Has Voice By Default * Default: true * When this is true, all dialogs will have a voice (when not specified, the default voice will play). * * > Voice Volume * Default: 80 * This sets the voice volume; values between 0 and 100. * * > Use Static Sound * Default: false * Whether to use the Static sound method. * When it is true, sounds will not overlap. * * > Fixed Voice Pitch * Default: false * If true, voices will play with a fixed pitch (which is 100 by default, you can modify with the command NMsgVoice.setPitch). * * > Voice Pitches * Default: 70 100 150 * A list of pssible voice pitches. * Values between 0 and 200, separated by spaces. * Ignored if Fixed Voice Pitch is true. * * If an invalid setting is given, a NMessageVoiceException is thrown. * Try-catch should work. * * --- Plugin Commands * These commands modifies the settings for the next dialog only. * To avoid conflicts with other plugins, each command has the prefix NMsgVoice.: * * > NMsgVoice.setName * This command sets the file name for the next dialog. * Example: * NMsgVoice.setName some_voice * * > NMsgVoice.setVolume * Sets the volume of the voice for the next dialog. * Values between 0 and 100. * Example: * NMsgVoice.setVolume 80 * * > NMsgVoice.setPan * This command sets the audio panning of the voice for the next dialog. * Values between -100 and 100, so -100 means "far left". * Example: * NMsgVoice.setPan -100 * * > NMsgVoice.setPitch * This command sets the voice pitch for the next dialog. * Values between 0 and 200. * Ignored if Fixed Voice Pitch is false. * Example: * NMsgVoice.setPitch 100 * * > NMsgVoice.setPitches * If Fixed Voice Pitch is false, sets the random voice pitches for the next dialog. * Values between 0 and 200, separated by spaces. * Ignored if Fixed Voice Pitch is true. * Example: * NMsgVoice.setPitches 70 100 150 * * > NMsgVoice.useFixedPitch * Sets the parameter Fixed Voice Pitch for the next dialog. * true or false. * Example: * NMsgVoice.useFixedPitch true * * > NMsgVoice.useStatic * Sets the parameter Use Static Sound for the next dialog. * true or false. * Example: * NMsgVoice.useStatic true * * > NMsgVoice.useDefault * Uses the default voice for the next dialog. * No parameters. * Example: * NMsgVoice.useDefault * * > NMsgVoice.hasVoiceByDefault * Sets the parameter Has Voice By Default for the next dialog. * true or false. * Example: * NMsgVoice.hasVoiceByDefault false * * If an invalid setting is given, a NMessageVoiceException is thrown. * Try-catch should work. * * --- enjoy u.u */ var Imported = Imported || {}; Imported.NOMID_Message_Voice = true; !function() { "use strict"; /******* UTILS *******/ // Try-Catch works function NMessageVoiceException(message) { SceneManager.stop(); AudioManager.stopAll(); Graphics.printError('NMessageVoice Exception', message); return new Error("NMessageVoice Exception: " + message); } function _parseBool(val) { return Boolean(val == "true" || parseFloat(val) == true || parseInt(val) == true); } function _param(what, typ) { var val = PluginManager.parameters("NMessageVoice")[what]; switch (typ) { case "str": return String(val); break; case "bool": return _parseBool(val); break; case "int": return parseInt(val); break; case "float": return parseFloat(val); break; } } function _falls_in_range(val, range, func) { if(parseFloat(range[0]) <= parseFloat(val) && parseFloat(range[1]) >= parseFloat(val)) return parseFloat(val); else NMessageVoiceException(func + "(): Value \"" + String(val) + "\" does not fall in the required range."); } function _parse_pitches(val, func) { if(typeof val === "object") val.forEach(function (v, i) { val[i] = _falls_in_range(v, [0, 200], func); }); else return _parse_pitches(val.split(" "), func); return val; } /******* UTILS END *******/ /******* PLUGIN PRIVATES *******/ var Voice = function(name, volume, pan) { this.name = name; this.volume = volume; this.pitch = 100; this.pan = pan || 0; }; var _pars = { has_voice_by_default: _param("Has Voice By Default", "bool"), voice_default: _param("Default Voice", "str"), voice: new Voice(_param("Default Voice", "str"), _param("Voice Volume", "float")), useStatic: _param("Use Static Sound", "bool"), fixed_pitch: _param("Fixed Voice Pitch", "bool"), pitch_list: _param("Voice Pitches", "str") }; var _default_pars = _pars; /******* PLUGIN PRIVATES END *******/ /******* OVERRIDES ********/ var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand; Game_Interpreter.prototype.pluginCommand = function (command, args) { _Game_Interpreter_pluginCommand.call(this, command, args); switch (command) { case "NMsgVoice.setName": _pars.voice.name = String(args[0]); break; case "NMsgVoice.setVolume": _pars.voice.volume = _falls_in_range(args[0], [0, 100], "NMsgVoice.setVolume"); break; case "NMsgVoice.setPan": _pars.voice.pan = _falls_in_range(args[0], [-100, 100], "NMsgVoice.setPan"); break; case "NMsgVoice.setPitch": _pars.pitch_list = [_falls_in_range(args[0], [0, 200], "NMsgVoice.setPitch")]; break; case "NMsgVoice.setPitches": _pars.pitch_list = _parse_pitches(args, "NMsgVoice.setPitches"); break; case "NMsgVoice.useFixedPitch": _pars.voice.fixed_pitch = _parseBool(args[0]); break; case "NMsgVoice.useDefault": _pars.voice.name = "default"; break; case "NMsgVoice.useStatic": _pars.useStatic = _parseBool(args[0]); break; case "NMsgVoice.hasVoiceByDefault": _pars.has_voice_by_default = _parseBool(args[0]); break; } }; Window_Message.prototype.processVoice = function () { _pars.voice.pitch = _parse_pitches(_pars.pitch_list)[Math.floor(Math.random() * _pars.pitch_list.length)]; if (_pars.voice.name == "null" || _pars.voice.name == "default") _pars.voice.name = _pars.voice_default; if (_pars.useStatic) AudioManager.playStaticSe(_pars.voice); else AudioManager.playSe(_pars.voice); }; var _WMESS_PROC_NORM_CHAR = Window_Message.prototype.processNormalCharacter; Window_Message.prototype.processNormalCharacter = function (textState) { if (_pars.has_voice_by_default) this.processVoice(); if (this.isEndOfText(this._textState)) _pars = _default_pars; _WMESS_PROC_NORM_CHAR.apply(this, arguments); }; /******* OVERRIDES END *******/ }();
Bug e conflitti noti
N/A
Termini di utilizzo
Credit & link me e il plugin
Allega File(s)
- voice_good.zip 9.39K 25 Numero di downloads
Modificato da ita_fox, 08 August 2016 - 11:35 AM.