[XP] Cogwheel MP3 Loop Pitch Issue (Need Help)

AveyondFan

Villager
Member
Joined
Sep 19, 2018
Messages
23
Reaction score
1
First Language
English
Primarily Uses
RMXP
I've been using an MP3 looping script based off of Cogwheel's script, and I do find that it does its job well, but there's just one issue that I can't seem to fix: due to how it has rewritten the way the system calls BGM, whenever I change the pitch of the music, once in the playtest, the music's pitch doesn't change. It stays at the default pitch, which is a bit annoying.
If someone would be willing to direct me to a similar script that doesn't have this issue or be willing to take a look at the script and tell me how to fix this issue, that would be great.

There is a script that is similar, and also happens to be based off of Cogwheel's script as well, but it also has the same issue. The link to the forum that I found that script on is here: http://www.creationasylum.net/index.php?showtopic=22365&hl=music&st=0

If you want to see the script I'm currently using so you can help me, please send me a message.

Any help will be very much appreciated. Thank you.
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
I'm ... FAIRLY..... familiar with your issue. ;) I made another variation of Cogwheel's system, adding an editor of sorts so you can pinpoint the start and stop points added multiple channels and a version of Near Fantastica's view range to control audio volume based on distance from the source. (If you're interested: Click >ME<.)

The issue you are experiencing is related to the audio format of your music or sound effect. You must be using .wma as your file format. You will find that .mp3, .Ogg and .mid allow you to alter the pitch. However, altering the pitch of a digital format such as .mp3 and .ogg will also slow down the playback and not just alter the pitch. It will be slooooooowwww and loowwwwwww.
 

AveyondFan

Villager
Member
Joined
Sep 19, 2018
Messages
23
Reaction score
1
First Language
English
Primarily Uses
RMXP
I was actually using MP3, not WMA. I'm aware that WMA has issues with pitch, but the issue wasn't with WMA not changing pitch, the issue was with MP3s, MIDI, and so on not changing pitch. When played in the sound test the pitch is correct, but when in the actual playtest, I.E testing the game, the pitch would be default (100) instead of say lower (such as 90) or higher (110).
I found what the issue of the pitch was in the script I'm using. It's a line of code that reads:
Code:
Audio.bgm_play(name, vol, 100) if name != ""
Changing the 100 changes the pitch. I looked at the default code for the BGM, and saw it read:
Code:
Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch)
From this I could gather that the script is causing the pitch to stay at the default 100.
I'm not a scripter, so I tried switching the 100 for bgm.pitch, but I kept getting the error: NameError Occurred. Undefined local variable or method 'bgm' for #<Game_Audio:0x2782f98>

I have the feeling that if I can change the 100 to something that will allow the pitch to work, I can fix the issue I'm having. Problem is, I don't know how, and I don't know why it's not working as I have no idea what the error even means.
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
In my MCISendString rewrite, I am able to adjust the pitch, by either script command, using the event command or by setting the music properties of the map.

And apparently, someone just downloaded it 4 1/2 Hours ago. ;)

fault code for the BGM, and saw it read:
Code:
Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch)
Yes, this is the 'bgm_play' method that is part of the (normally hidden) AUDIO class. Here, the code is accepting legitimate values of the audio file's name, volume and pitch. So there would be THREE values to set. AHA! You set the pitch and entered bgm.100, didn't you! Just replace the whole value.

Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, 125)


Now if you get THAT to work, then the problem won't be the actual mechanics of the engine. It could be the resulting file that is generated where you are programming the loops.
 

AveyondFan

Villager
Member
Joined
Sep 19, 2018
Messages
23
Reaction score
1
First Language
English
Primarily Uses
RMXP
May I post the scripts here (they're not mine, but I think they would be helpful for this conversation)? I don't think I got what I meant to say across (that or I'm completely not understanding what's being said at all).
I did not enter bgm.100. I put bgm.pitch in the place of the 100 because that's how the default scripts call the pitch.
Taken from Game_System:
Code:
#--------------------------------------------------------------------------
  # * Play Background Music
  #     bgm : background music to be played
  #--------------------------------------------------------------------------
  def bgm_play(bgm)
    @playing_bgm = bgm
    if bgm != nil and bgm.name != ""
      Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch)
    else
      Audio.bgm_stop
    end
    Graphics.frame_reset
  end
It's after I do this to the script I'm using:
Code:
Audio.bgm_play(name, vol, bgm.pitch) if name != ""
that I get the error stated in my previous post, and I don't understand what "NameError Occurred. Undefined local variable or method 'bgm' for #<Game_Audio:0x2782f98>" means so I'm hitting roadblocks because of that.
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
Okay. Let me take a pot-shot guess.
Code:
    if type == "Normal"
      bgm_stop(type) if @name != name
      Audio.bgm_play("Audio/BGM/" + name, vol, 100) if name != ""
    elsif @name != name
.... is it 'HERE' that you replaced 100 to bgm.pitch? You woulda been close. Technically, you should have just entered pitch if the method was defined thus:
Code:
bgm_play(name, vol, pitch, type, start, loop, fin)
But if I'm right, this version didn't account for altered pitch for your custom looped audio, only the default ones you didn't touch. You'll likely find a setaudio within the AUDIO class's bgm_play method to handle audio for the custom audio, but nothing to set the playback pitch.

What is likely present....
Code:
        @play.call("Setaudio " + type + " volume to " +
          (vol ** 2 / 10).to_s, "\" * 255, 255, 0)
What I included in mine...
Code:
object[channel].call("Set " + type + " speed " + pitch.to_s, "\0" * 255, 255, 0)
(Mine's more complicated because of multiple channels)

This might work if you can insert it after his volume statement above (based on mine)
Code:
        @play.call("Set " + type + " speed " + pitch.to_s, "\0" * 255, 255, 0)
 

AveyondFan

Villager
Member
Joined
Sep 19, 2018
Messages
23
Reaction score
1
First Language
English
Primarily Uses
RMXP
The issue with this is that the version you have simply changes the speed. I did download yours and tested it in the demo, but when I changed the music's pitch, all it did was slow it down. It didn't change the pitch up or down.
It is using the pitch's number, but instead of using it to change the pitch (the key it's playing in), it's using it to change the speed (the tempo it's playing in).
Should I just send you the two scripts (there are two; one to define the audio changes, the other for designating the BGM to be looped, though I think the first might be the more relevant one)? I think you could help me a bit more if you had the script.

Also, if comparing scripting language to a spoken and written language, I'm pretty much at a newborn's level of being able to read scripting, so please forgive my cluelessness. Why did you put quotation marks around the word speed? I'm asking, because I'm wondering if I could somehow modify what you've given me so that it changes the key instead of the speed.
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
Oh, there is definitely a marked difference during playback with the digitally recorded music files within my demo, both tonally and in regards of speed playback. Setting the very first event with the green button (playing 'Mark II' from Iron Man), a pitch setting of 50 reduces speed to half speed and substantially lowers the tone. Likewise, increasing its pitch setting to 150 increases the playback speed to 50% faster than normal with a higher pitch. I have done this with both the default Event code as well as the custom BGM_Play commands that allow for channel use. And I am typing this while actively playing my demo, so this is not in doubt. This is how the mcisendstring system will handle pitch for audio.

To actively change pitch while keeping the speed the same cannot be performed by the mcisendstring system that is used by Win32 API calls. One would need to directly edit the files with some audio editing system like Audacity. Seen it. Done it.

Now as to why I used quotes around the phrase "speed" in the @play.call command, the command being sent into the mcisendstring must be a complete string in itself. Once the variables are filled in, the statement of :
"Set " + type + " speed " + pitch.to_s becomes
"Set normal speed 150" .... if the pitch is set to 150

Before you ask, there is no MCI command to set the pitch alone. Speed is the only option with the MCISendstring. But since the 'speed' playback for Midi is fixed and cannot be changed, you only hear the tonal pitch change for midi music and no difference in speed. Likewise with Windows's .WMA format. It too has a fixed duration, so speed won't be affected. But that means tonal change won't work with WMA.
 

AveyondFan

Villager
Member
Joined
Sep 19, 2018
Messages
23
Reaction score
1
First Language
English
Primarily Uses
RMXP
What I really want to know is how the default script (not the cogwheel, the scripts that come with RPG Maker XP by default) calls the pitch. I'm almost certain that there's a way to do it without changing the speed.

Also, I did try your script.
The music I used (an MP3 file) to test it did not change its pitch. It only changed its speed. If the script did what I wanted I wouldn't still be trying to figure out how to rewrite the pitch without using your method.
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
What I really want to know is how the default script (not the cogwheel, the scripts that come with RPG Maker XP by default) calls the pitch. I'm almost certain that there's a way to do it without changing the speed.
Sorry. But I decided to copy a track from the Hellsing OST: Raid into a fresh and untouched project. Track 1: The World Without Logos. Even in the editor, setting the pitch up 150 plays the audio by default at 50% faster speed to change its pitch. And setting the pitch to 50% in the editor itself plays it at an appalingly slow speed. I could hardly understand anything sung from the Helsing OVA's opening theme.

With these tests, the system employed by the MCISendstring routines initially developed by Cogwheel mirrors that of RPGMaker XP's audio system insofar as pitch and speed. Just how much or little pitch change are you using? If you're just making a 10% change, you won't really notice jack about the speed.

(Yep, still playing the OST piece right now)
 

AveyondFan

Villager
Member
Joined
Sep 19, 2018
Messages
23
Reaction score
1
First Language
English
Primarily Uses
RMXP
Uhh....
Okay, I need to apologize. I was in error.
I just tested in the main RPG Maker XP sound test...
You're right. It does change speed in MP3 files.
I put it down to 50% and, you're right, MP3 does change speed as well as pitch in vanilla RPG Maker XP.
I'm sorry.
I feel very silly now. I've been hitting my head against a wall for no reason for the last month or so. I'm sorry about the trouble I put you through.
Why is it becoming a trend of me thinking I know what I'm doing and I know things when I'm not and don't?
Sorry about that.
Just a bit of an amusing sidenote, I wanted to share the... experience of me realizing I was in error:
*Puts an MP3 song down 10% and plays it*
...
*listens closely*
Wait a second...
*puts it at 50% and plays it*
...Oh...
 
Last edited:

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
It happens. Dinna worry about it, Lad. Wow, Star Trek Scotty moment.

Any other issues with the Cogwheel-based systems? I tell ya, getting looping down to 1/1000th of a second is HELL. And getting OGG to loop properly with their screwy readings is unbearable. Thank Gawd that MP3 is no longer copyrighted and is now a Royalty Free format.
 

AveyondFan

Villager
Member
Joined
Sep 19, 2018
Messages
23
Reaction score
1
First Language
English
Primarily Uses
RMXP
That's it, actually. Thanks for being patient with me while I was having that derp moment.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top