Sound Problem on Mac (latest version)

Previous topic - Next topic

mrplant

I have my game and compile it for Mac with latest GLBasic. I also compile same source code with an older version (10.118) and comparing the two games sound output is like night and day.
The latest version  has the odd loud transient when a rock falls - the rest of the falling rocks are much lower in the mix...
With 10.118 the sound is clear and full bodied and full volume..
Hard to put this into words  - maybe I will have to post a link to a test video clip or something..
I had to compile my game with 10.118 so I could submit my binary to the iPhone app store (my app also compiles for the iPad). The sound is great on 10.118.

As I say exact same source code that I have been developing for months now (6 in fact). As a test - I converted all my .wav files (they are short .wav files) into .caf files and compiled and ran on the latest version of the compiler on Mac - and this surprised me but not an ounce of change - it sounded exactly like the .wav file did on the latest compiler).

Hope this helps describe the problem but I have no idea what is going on...
I hate reporting problems... but I have to here... sorry... :-(

Kitty Hello

I try to find the bug. So sorry :(

mrplant

No problem Kitty Hello - I just think maybe unless you are firing off a few sounds quickly it may be hard to detect..

I would like to help you track it down if you want..

I could try and knock up a small demo that might show up the problem..

Kitty Hello

Test this, please. If it works, please use the SoundEnding.dylib in Contents/MacOSX/ in your project. Does it fix the issue?



[attachment deleted by admin]

mrplant


mrplant

Hi

Your demo played ok.
I then compiled my project with latest glbasic and replaced the sound library file inside the mac runtime like you said.

Unfortunately it didn't fix the problem - in fact one of the sounds failed to play at all that had played low before.

It seems to be volume related over time.

I am going to PM you shortly.

mrplant

#6
I am doing more detailed testing now...

it turns out that in fact on the Mac.. the version compiled with 10.118 has lower sounding rock fall sounds and the 10.144 version has the same level but sometimes fires off a Louder sound than any other version.

That is the opposite to what I originally thought was happening. I thought the 10.144 was lower and occasionally louder - its the other way around - its occasionally too loud.

I just tested again by dropping in your new sound library and it is the same as the 10.144 one in effect - the rock sounds go really louder then normal again.

*If I drop the 10.118 version of the sound library into the 10.144 compile - it doesn't play any WAV sound at all - probably due to things changed between those versions..

spacefractal

Another through: is the sample played twice as same time? And then it's sound louder?
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

mrplant

It could be that it is played twice at same time - there is no discernible delay or echo on it though..

spacefractal

samples allways is louder when its played twice extracly same time.

You can actuelly try to output what its play each time its play a sound (etc you came to call it twice)? Then you will found out its a bug in your app or in glbasic (etc its only happens on one platform).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

mrplant

The problem may in fact be with  my code... although differences between windows and mac may be showing it up..

On windows its fine as I always said..

On 10.118 and 10.209 the mac sound is ok but on 10.244 it is not..

Imagine a man is walking under 5 rocks - when I move those 4 rocks down - I am firing off a sound effect every time I move down each of those rocks - I do it all at once however so they get fired off real quickly in a loop.
I just changed my rockfall routine to only play one sound at the end of moving all the rocks down and the effect is ok actually and the sound doesn't  jump up...

// Loop to draw in the rocks, moving upwards (starting from the bottom of the mined earth found)
   FOR LoopIntY = MinedEarthScan TO MinedEarthScan - (RockCount-1) STEP -1

      // Draw up Rock into Backbuffer.
      DRAWSPRITE gRock,OldDanX*BSize, LoopIntY*BSize
      LoopIntX = LoopIntY

      IF GameMode <> 1 // Don't play sounds in silent mode
         PLAYSOUND (sRockFall,-Pan,1) // Play Rock Fall sound, panned according to player move direction, reversed!
      ENDIF

      Screen$ [OldDanX-1][LoopIntY-1] ="R" // Update in memory array location as a "Rock"
   NEXT


thats my current code - as I draw each moved rock into position I quickly fire of a sound effect - this means if man walks under 2 rocks its slightly different to walking under one rock.

Whereas if i modify my code to:

   // Loop to draw in the rocks, moving upwards (starting from the bottom of the mined earth found)
   FOR LoopIntY = MinedEarthScan TO MinedEarthScan - (RockCount-1) STEP -1

      // Draw up Rock into Backbuffer.
      DRAWSPRITE gRock,OldDanX*BSize, LoopIntY*BSize
      LoopIntX = LoopIntY
      Screen$ [OldDanX-1][LoopIntY-1] ="R" // Update in memory array location as a "Rock"
   NEXT
   
   IF GameMode <> 1 // Don't play sounds in silent mode
         PLAYSOUND (sRockFall,-Pan,1) // Play Rock Fall sound, panned according to player move direction, reversed!
   ENDIF

The playsound is out the loop and I only call it once no matter how many rocks are falling..

This works and sounds ok - but up till now on 10.118 and 10.209 the original code has sounded ok on the mac when moving . So it seems related to this and the amount of buffering and delays??

mrplant

#11
Maybe I should look into recording different sound effects instead - one of one rock falling, one of two rocks falling, on of 3 etc. and play back the appropriate sound effect once instead?

Then again.. if a space ship fires 5 lasers quickly - isn't that the same..

Still wondering if this is a consequence of my coding or something else..

mrplant

I recorded new sound effects called Rockfall1 up to Rockfall5 that playback at once 1 to 5 rocks falling with slight delays between sound - I put them into the game and the overall effect is quite nice and seems to sound ok now on the Mac.

My huge apologies to Hello Kitty for wasting your time today if it turns out this was a consequence of my coding but it never showed up before on the Mac - so maybe  a side effect of new sound code in GLBasic combined with my own slightly flawed game logic..

fingers crossed and further testing here but this sounds much better so far..

spacefractal

You haven't checked if sample already played if to rocks fall same time, so play sound might have invoked twice. If yes, that why it's louder.

The new code is more correct to make sure only play once.

I guess its was a bug which just have been fixed in a newer version (etc it's did not use more than one channel), and hence invoked a unseen bug in your code....
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

mrplant

#14
Just to confirm - I have made code changes to the way my app plays sounds. I recompiled and tried all my targets - Windows, Mac and iPad and the new code works as I expect it to after a few hours play testing..

It does seem what was happening was a combination of my bad code and some newer changes in the OpenAL code in GLBasic.

Hello Kitty - your sound engine code seems to be working fine on Mac now I have corrected my bad code - just so you know.

[edit / Kitty] Thanks! I'll close that topic then.