Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [BUG] SetSoundInstanceRate Not Changing Sound Sample Speed

Author
Message
Muckypaws
AGK Developer
13
Years of Service
User Offline
Joined: 21st Oct 2011
Location:
Posted: 1st May 2015 02:14
Hi,

Ok, I\'m just putting the sound into Manic Miner, and I found a command early on which lets me set the rate of a sound (I assume changes the frequency) so I can use one sample and bend it.



This was a similar strategy I used when I coded the DirectX version in the 90\'s.

GetSoundMaxRate returns 2.0
GetSoundMinRate returns 0.5

So it must be possible, however the samples I have do not change frequency when played at all (.wav)

Am I doing something fundamentally incorrect here? Or is there a bug in the command?

I\'m on Mac OSX 10.10.3, but it occurs on Other OS X OS\'s also.

Many Thanks
Muckypaws.

[href]https://www.facebook.com/WonkyPix
http://www.wonkypix.com
http://www.appstore.com/jsecconsultancyltd[/href]
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st May 2015 10:13
It doesn't work like that.

PlaySound() returns an instance. You modify the instance for rate or pitch.



That's with no error-checking. The Instance value becomes invalid when a sound ends.

<<It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.>> Dijkstra
Muckypaws
AGK Developer
13
Years of Service
User Offline
Joined: 21st Oct 2011
Location:
Posted: 1st May 2015 14:43
HI Jim,

Thank you....

Yes that works, User Error *Hangs Head in Shame*


Lol...

[href]https://www.facebook.com/WonkyPix
http://www.wonkypix.com
http://www.appstore.com/jsecconsultancyltd[/href]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st May 2015 18:33 Edited at: 1st May 2015 18:33
Quote: "Yes that works, User Error *Hangs Head in Shame*"




Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Attachments

Login to view attachments
Jambo B
15
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 1st May 2015 21:41
Ha! Don't feel bad - I made the same mistake!

James
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 2nd May 2015 00:41 Edited at: 2nd May 2015 00:41
I assume it works like this:

There is a limited number of simultaneous sounds - platform dependent.
But you can "load" a large number of sounds. When you play a sound it occupies a "slot" in the limited array of available actual sounds. This is the instance - an index into the limited array.

Big pool of sounds: [1..339] of whatever.
Dynamic slots: [1..32] perhaps?

PlaySound(231) looks for an empty slot in the dynamic slots, starts the sound in that slot and returns the slot index (the instance). Suppose there are sounds in slots 1 and 2:

[1] Bang1.wav playing
[2] Zap44.wav playing
[3] <Empty>

PlaySound(231) returns 3. Operations like SetSoundInstanceRate() use the index 3 to manipulate that playing sound. That's NOT the same as the ID of the sound loaded into memory but not played.

Unless the sound is looped, when it reaches its end slot 3 becomes empty again. So LoadSound() return a static number - whereas PlaySound() returns a dynamic number. There are methods to check if an instance is playing before bending it, or whatever you want to do.

Maybe Paul can confirm that this is the case.

<<It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.>> Dijkstra
Muckypaws
AGK Developer
13
Years of Service
User Offline
Joined: 21st Oct 2011
Location:
Posted: 2nd May 2015 02:14
@BatVink, @Jambo, lol very funny

@Jim, In the end I couldn't make it do what I wanted it to do, so I sampled the original notes and loaded them to a linked list for processing later. It works quite well.

In my original, I could load the sound into a DirectSound Buffer and manipulate the frequency relatively easy.

I'm sure there must be a way of making it work this way, but I went with the path of least resistance

Thanks everyone for your help

[href]https://www.facebook.com/WonkyPix
http://www.wonkypix.com
http://www.appstore.com/jsecconsultancyltd[/href]
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 2nd May 2015 09:56
LoadSound() does load into a buffer, so you should get pretty-well instant play using it after that point.

<<It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.>> Dijkstra

Login to post a reply

Server time is: 2024-11-25 21:50:51
Your offset time is: 2024-11-25 21:50:51