MZ Help excluding certain characters from playing a sound in dialogue?

Hey there, apologies if this isn't the correct forum.

I'm using ovate's Message Sound Effect - Dialogue Blip plugin, especifically RedJelly's modifications to allow for random pitch. Works perfectly and does exactly what I want, except for one thing. It plays the sound on periods, commas, and spaces, which I don't like.

I was wondering if there is a way to add an "exception list" to the plugin, where I could add certain characters (like ?, !, ', etc) which I don't want to play a sound. I'm fine with having to edit the code directly to add more characters there. That's all, thanks in advance!
Hmmm, make an edit to the below method in the plugin. So I added the line where it stores the letter at the current index and then added && to the conditional to check if a list you can write there includes that letter. But since I'm not a pro with that textState stuff, you should test if that works with control characters etc

Window_Message.prototype.processCharacter = function(textState) {
if (Utils.RPGMAKER_NAME == 'MV') {
_Window_Message_processCharacter.apply(this, arguments);
} else {
const length = textState.buffer.length;
_Window_Message_processCharacter.apply(this, arguments);
const letter = textState.text[textState.index];
if (length !== textState.buffer.length && !["?", "!", ","].includes(letter)) {
this._charSeCount--;
}
}
};
Hmmm, make an edit to the below method in the plugin. So I added the line where it stores the letter at the current index and then added && to the conditional to check if a list you can write there includes that letter. But since I'm not a pro with that textState stuff, you should test if that works with control characters etc

Window_Message.prototype.processCharacter = function(textState) {
if (Utils.RPGMAKER_NAME == 'MV') {
_Window_Message_processCharacter.apply(this, arguments);
} else {
const length = textState.buffer.length;
_Window_Message_processCharacter.apply(this, arguments);
const letter = textState.text[textState.index];
if (length !== textState.buffer.length && !["?", "!", ","].includes(letter)) {
this._charSeCount--;
}
}
};
thanks for the help!

I did the editing and it works fine!

However I realized another issue, which is that a sound automatically plays whenever each line is done displaying. And also at the start of each message box. So if there's an empty box for instance, a sound will play.

Is there a way to fix that or is that out of the scope of this?
The SE plays when the charSeCount <= 0. The plugin sets it to 0 in clearFlags that would happen at least when a message page changes/ends. So you can modify two methods like this (first one I added the _noCharSe tag line and second one I put the else branch at the bottom [edit: + added the condition in the above conditional]). It's not immediately obvious to me what would cause it to play the sound at the end of each line.

const _Window_Message_clearFlags = Window_Message.prototype.clearFlags;
Window_Message.prototype.clearFlags = function() {
_Window_Message_clearFlags.apply(this, arguments);
this._charSeIndex = $gameMessage.charSeIndex();
this._charSeCount = 0;
this._noCharSe = true;
};

Window_Message.prototype.updateMessageSe = function() {
if (this._charSeIndex > 0) {
const se = param_CharacterSes[this._charSeIndex - 1];
if (se && this._charSeCount <= 0 && !this._noCharSe) {
var pitchInit = se.pitch;
var pitchVar = Number(se.pitch) + Math.floor((2*(Math.random()-0.5))*param_PitchVariance);
se.pitch = pitchVar.toString();
// console.log(se.pitch);
AudioManager.playSe(se);
se.pitch = pitchInit;
this._charSeCount = param_SeInterval;
} else {
this._noCharSe = false;
}
}
};
Hm, maybe something is going wrong with the plugin or with what I'm doing. I did the changes, however the behavior seems to vary depending on the Se Interval. When I have it at 3 (the one I'm using for my game) it plays the sound at the end of the text only sometimes, I can't really get why. Whe I have it at 1 then it plays everytime, and at 4 it only plays at the end of the message. And of course always at the start, that one is consistent. I have no idea what's causing anything or how to explain it, but I can send a video of the sound playing and of the example text in-project if that would help? Thanks anyway, I appreciate it
Hmmm I tested it with interval 1, and the edits above seemed to stop at least some of that happening. Like certainly empty message boxes didn't play the sound anymore.
Yeah it manages to stop some of the sound sometimes but othertimes not, I am not quite sure. Either way I think I might keep it like this, it does most of the things I want anyway. Thank you!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/help-excluding-certain-characters-from-playing-a-sound-in-dialogue.182255/