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.

DarkBASIC Professional Discussion / Playing Sound at Millseconds

Author
Message
Sakuya
17
Years of Service
User Offline
Joined: 16th Feb 2009
Location: IB*ET
Posted: 21st Apr 2010 23:03
Infact this is the first time for me using Sound Commands and there wasn't realy something difficult to understand.

Although I was wondering as I wanted to Loop a MP3 at Millisecond precision so the sound which restarts at a given Position doesn't sound wierd.

I searched but the only Plugin I saw was Dark Audio or something like this. It couldn't help me because I still need Milliseconds instead of Seconds.

Is there a Workaround, a Plugin I missed?
MayoZebraHat 1979
18
Years of Service
User Offline
Joined: 21st Dec 2007
Location:
Posted: 21st Apr 2010 23:08 Edited at: 21st Apr 2010 23:09
Try this one: http://forum.thegamecreators.com/?m=forum_view&t=111325&b=8

It lets you set the position based on frames... which I think would be the a high enough form of precession for seeking in an audio file of any kind.
Sakuya
17
Years of Service
User Offline
Joined: 16th Feb 2009
Location: IB*ET
Posted: 21st Apr 2010 23:12
ohh I completely forgot to check the WIP
very thanks

Ill check in a minute, preparing food...
Sakuya
17
Years of Service
User Offline
Joined: 16th Feb 2009
Location: IB*ET
Posted: 22nd Apr 2010 00:23 Edited at: 22nd Apr 2010 00:24
Ok I tested it and this is what I searched for.

But now I got another problem:
I want to position the Sound back to a previous Position so it seems like the loop would go on for ever.
The problem's now that I checked with Sound Editor at which frame I should reposition the Sound. Well it simply doesn't catch the Audio Frame at that given Number, I suppose the Sound just passes that check because the Frames are changing faster than the main loop does.
MayoZebraHat 1979
18
Years of Service
User Offline
Joined: 21st Dec 2007
Location:
Posted: 22nd Apr 2010 03:51 Edited at: 22nd Apr 2010 03:54
I use Fmod for just about everything so I'm sorry I can't help more with these two. The native sound library Loop Sound function really should do this for you. You have a song that has an intro, you want it to loop through the main part of the song after the intro, right? And the position commands of the Loop Sound function seem to work on a sample level for me so you should just pick your sample range and loop from that using

LOOP SOUND Sound Number,Start Position,End Position,Initial Position

The initial position would be 0 and the start and end should be your looping samples. When you said "sounding weird" in the first post what did you mean? Waves tend to pop unless they the loop points start and end data are close. Otherwise you'll get a click.
Sakuya
17
Years of Service
User Offline
Joined: 16th Feb 2009
Location: IB*ET
Posted: 22nd Apr 2010 13:20
Oh I can use Fmod with DBPro? Didnt think about it, I once used it with Delphi, gotta check this out too.

By Weird Sound I meant that when listening carefully you wouldnt recognize when the sound would start to loop at the specified position, that's why I needed more precision with milliseconds/frames instead of seconds.

For the LOOP SOUND I thought those parameters where taken like seconds?
chunks chunks
19
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 22nd Apr 2010 14:07
I will have a look at the sound code for dbpro if i can get the pointer to the buffer you can return the read and write position it will prolly be in frames but might be able to convert them to millisecs , will have a look tonight and if i can will post the extra commands in the sound dll , although thats for wavs only.

It was i who wrapped that mp3 library , it does have millisecs , if i cant get the wavs to work , i will write you a little demo for milliseconds in dark audio/dark mp3 .

perhaps you could post the particular sample you are using and a little description on what you are doing with and i will see if i can fix or help you on this .


chunks

nvidia geforce 9500gt + amd athlon 64
windows vista ultimate.
Sakuya
17
Years of Service
User Offline
Joined: 16th Feb 2009
Location: IB*ET
Posted: 22nd Apr 2010 14:35
Hei chunks

I attached the sound as mp3 and wav.
What I want to do is when the Battle in my Game begins the Sound starts and then loops between 2 given positions. Then I stop it when the battle's over.

LOOP SOUND would do it but I just can't get it what is meant by Position in Bytes. Im using Audacity to check the Positions where the Sound should loop altough it can't show me the positions in "bytes", it has seconds,milliseconds,frames,samples and such but nothing like bytes
chunks chunks
19
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 22nd Apr 2010 22:24 Edited at: 22nd Apr 2010 22:26
hi try this way , read the readme and try the example and see if its accurate enough , you can convert the bytes per seconds into milliseconds but im not really sure how its done + i didnt have time .

chunks

nvidia geforce 9500gt + amd athlon 64
windows vista ultimate.
Sakuya
17
Years of Service
User Offline
Joined: 16th Feb 2009
Location: IB*ET
Posted: 23rd Apr 2010 16:52 Edited at: 23rd Apr 2010 17:21
I tried it and yeah I got the desired effect.
Thanks alot

Is there a Possibility that You could add a Command to get the length of the wav in Bytes? That way I could convert the Bytes to Samples or other format.

EDIT:
I think I got something, correct me if Im mistaken.
For example a 32Bit Wave would mean
32 Bits = 4 Bytes
that means 4 Byte per Sample

So basicaly if I want to convert Sample(Which I can read from Audacity) to Bytes I need only to do (for 32Bit Wave):
PositionInSample * 4 = PositionInBytes

Correct?
chunks chunks
19
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 23rd Apr 2010 22:49
here ya go there is extra info in the sound memblock which are usefull for you .




chunks

nvidia geforce 9500gt + amd athlon 64
windows vista ultimate.
Sakuya
17
Years of Service
User Offline
Joined: 16th Feb 2009
Location: IB*ET
Posted: 24th Apr 2010 00:07
Hooo

Thats realy interesting. Very good to know.
Because I checked with Audacity how many Bits Per Sample the Waves had. But this is also handy as I get precise Information.

Thanks alot Chunks your Help was very usefull!

Login to post a reply

Server time is: 2026-07-27 20:18:04
Your offset time is: 2026-07-27 20:18:04