Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411840 Posts in 69419 Topics- by 58464 Members - Latest Member: Riya21

May 31, 2024, 06:26:18 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The grumpy old programmer room
Pages: 1 ... 84 85 [86] 87 88 ... 295
Print
Author Topic: The grumpy old programmer room  (Read 741670 times)
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #1700 on: February 19, 2011, 02:05:13 PM »

Aaaaaah.

30 FPS.  :D  (For some reason I use 40.  I don't notice vsync.  <_<)


In other news, I can't get my audio driver to let me render audio in less than quarter-second pieces.  My audio engine works like a dream except it has a THIRD OF A SECOND OF FUCKING LATENCY WHEN TUNED TO A MINIMUM GRAAAAARGH

However, it renders audio at 40 FPS.  Gentleman
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
Triplefox
Level 9
****



View Profile WWW
« Reply #1701 on: February 19, 2011, 05:27:28 PM »

In other news, I can't get my audio driver to let me render audio in less than quarter-second pieces.  My audio engine works like a dream except it has a THIRD OF A SECOND OF FUCKING LATENCY WHEN TUNED TO A MINIMUM GRAAAAARGH

There are some fundamental platform API limitations on latency.

This is why on Windows-based DAWs, to get <50ms latency you have to go set up ASIO, get a "pro" sound card with working drivers, etc. etc. On Linux, you have to compile a real-time kernel, give audio scheduling priority, etc. etc. I think OS X is the only one of the major desktops that actually got this right from the beginning. And every console and mobile device has its own thing of course, but you can at least hope to have a semblance of low-level control with them. I've never delved deep enough into the topic to actually deal with this stuff.

Random link:

http://stackoverflow.com/questions/2010400/best-api-for-low-level-audio-in-windows

On Windows in particular, you can expect the average user to be using a generic "AC97" or "HD Audio" driver that pulls some serious bullshit and adds 300ms of latency or something. Microsoft also rewrote their audio in the transition to Vista with mixed results(mixing per-app, and better latency, I think, but also breaking a lot of drivers and apps in the process). Most PC games don't actually deal with the problem(building off a high level API like DirectSound or SDL sound, and never doing any signal processing) and live with the mediocre results.

This is probably a third-hand story now, but I recall reading that way back when in the late 90's, Flash used a CPU-intensive timer to get decent A/V sync. Microsoft told them to reduce average-case power consumption and cut it out, and after that sound in Flash became hilariously delayed. Since Flash 10 I think they've changed things around again, as the latency seems better now...
Logged

Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #1702 on: February 19, 2011, 05:36:04 PM »

I'm familiar with most of that factology.

I should have clarified: the latency is specifically because I have to render my audio in quarter-second blocks.  I'm not expecting (and don't need) ASIO latency, but when I can't render less than a quarter of a second at a time I have 500 milliseconds of latency when I'm *not* cheating, before the audio even gets to the driver.

I was pretty sure it was almost always possible to use a ~2048-sample buffer.  :\
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
mcc
Level 10
*****


glitch


View Profile WWW
« Reply #1703 on: February 19, 2011, 06:00:32 PM »

You'd be surprised how big audio latencies can get without it being noticeable.
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #1704 on: February 19, 2011, 06:02:16 PM »

Though, I'm probably worrying too much about that anyway.

I've schooled myself.  But when it's an immediate reaction to a keystroke, .33 seconds just doesn't seem to cut it.  :\

I'll figure something out.
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
J. Kyle Pittman
Level 6
*


PostCount++;


View Profile WWW
« Reply #1705 on: February 19, 2011, 09:39:04 PM »

It would be a lot easier to test net code if my internet didn't go out every couple of days.  Angry

Sent from my iPhone
Logged

Triplefox
Level 9
****



View Profile WWW
« Reply #1706 on: February 19, 2011, 11:12:13 PM »

Oh, I think I understand. Maybe. I give Flash a buffer of 4096, and it's slow, but I've gone with with the idea that events aren't so heavily tied to user input. If I were trying to make anything requiring the user to play it like an instrument and actually pay attention to the feedback, I would be seriously worried about the driver-level situation. If you have >50ms timings you will absolutely notice it; you won't even able to play in rhythm well anymore. And, just as importantly, we'd want to get close to "hard real-time" if possible - not a floaty "sometimes 20ms sometimes 100ms" responsiveness - which is what the user will percieve by having a low render framerate.
Logged

Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #1707 on: February 20, 2011, 11:48:16 AM »

Man, I'd be just fine with 4096 right now.  :\  I've got 12000.
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
Lon
Level 4
****



View Profile
« Reply #1708 on: February 20, 2011, 08:49:20 PM »

After spending entirely too much time (like maybe hours  Screamy) with with a simple, yet frustrating, error I've finally stumbled upon a hack fix. So glad to have made progress, but I still don't understand how to fix it proper like, and online documentation isn't helping.

Frustrating that the code is not functioning as I understand it to behave.  VERY frustrating that online documentation isn't helping.
Logged

“We all sorely complain of the shortness of time, and yet have much more than we know what to do with. Our lives are either spent in doing nothing at all, or in doing nothing to the purpose, or in doing nothing that we ought to do..." -Seneca
resistor
Level 0
**


View Profile
« Reply #1709 on: February 21, 2011, 12:54:18 AM »

Have you tried declaring firstBlock as volatile? That should scare the optimiser away.

Will

Right!  Thank you; forgot about that one.  I found a way around it but waiting is better.

You need to be very, very careful with this.  Volatile will prevent the compiler from removing the loop, but there are much more serious issues that can crop up when you try to rely on the ordering of memory reads/writes across threads.  Even with the compiler scared off, it's entirely possible to get situations like this:

T1:  Write A, Write B
T2:  Wait for A, Read B

Where the writes in T1 get reordered and T2 ends up reading the wrong value for B.  While X86 is pretty sane in regards to the reorderings it can do, ARM and PowerPC are both much more lax in the guarantees they give you.  To avoid this kind of possibility, you need to use some form of atomics/memory barriers (GCC's are at http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html).

To see more about how this kind of issue can come up, see Hans Boehm's "Threads Cannot Be Implemented As A Library" : http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.90.2412&rep=rep1&type=pdf
Logged
Glaiel-Gamer
Guest
« Reply #1710 on: February 21, 2011, 01:00:13 AM »

Jon and I made a game this weekends for a 3-day newgrounds game jam.

The words "fuck", "fuck you", "god damn", "FUCKING SHIT", and "FLASH!"  and combinations thereof were uttered on the order of thousands of times this weekend....


the result came out well but now i remember why i haven't used flash in months

http://www.newgrounds.com/portal/view/562939
Logged
Will Vale
Level 4
****



View Profile WWW
« Reply #1711 on: February 21, 2011, 01:43:33 AM »

You need to be very, very careful with this.

Totally agree, but there wasn't any context in the original post Smiley I guess I'm spoiled by the platform I use most often making it very easy to serialise memory transfers so I don't tend to think about it Sad

Also a minor nitpick, sorry:

Quote
T1:  Write A, Write B
T2:  Wait for A, Read B

Should that be

Quote
T1:  Write B, Write A
T2:  Wait for A, Read B

as the case which can get broken by reordering? As posted, it's broken if the writes execute serially as written.

Will
Logged
resistor
Level 0
**


View Profile
« Reply #1712 on: February 21, 2011, 01:53:00 AM »

Also a minor nitpick, sorry:

Quote
T1:  Write A, Write B
T2:  Wait for A, Read B

Should that be

Quote
T1:  Write B, Write A
T2:  Wait for A, Read B

as the case which can get broken by reordering? As posted, it's broken if the writes execute serially as written.

Yes, sorry.  That's what happens when I write things while sleepy.  Smiley
Logged
st33d
Guest
« Reply #1713 on: February 21, 2011, 04:07:52 AM »

Jon and I made a game this weekends for a 3-day newgrounds game jam.

The words "fuck", "fuck you", "god damn", "FUCKING SHIT", and "FLASH!"  and combinations thereof were uttered on the order of thousands of times this weekend....


the result came out well but now i remember why i haven't used flash in months

http://www.newgrounds.com/portal/view/562939

ho ho, errors:
Code:
ReferenceError: Error #1065: Variable Timeline_5 is not defined.

ReferenceError: Error #1065: Variable NewgroundsAPIAsset_FlashAd_Container_30 is not defined.

ReferenceError: Error #1065: Variable NewgroundsAPIAsset_Load_Indicator_10 is not defined.

SecurityError: Error #2000: No active security context.

I feel your pain.
Logged
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #1714 on: February 21, 2011, 07:13:14 AM »

For whatever it's worth, the busy-loop was a necessity owing to my use of reentrant mutexes; I just needed to wait for a thread to start and trip a boolean before I proceeded.

I'm doing things differently now so that's no longer necessary.
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
Glaiel-Gamer
Guest
« Reply #1715 on: February 21, 2011, 10:23:00 AM »

ho ho, errors:
Code:
ReferenceError: Error #1065: Variable Timeline_5 is not defined.

ReferenceError: Error #1065: Variable NewgroundsAPIAsset_FlashAd_Container_30 is not defined.

ReferenceError: Error #1065: Variable NewgroundsAPIAsset_Load_Indicator_10 is not defined.

SecurityError: Error #2000: No active security context.

I feel your pain.


they're all from the advertisements and i couldn't suppress them for some reason
Logged
st33d
Guest
« Reply #1716 on: February 21, 2011, 11:58:21 AM »

Statement retracted.

It's a pity you can't just try-catch a whole ad these days.

(Mind you - I'll say this seeing as it's unlikely our pre-roll advertisers will see this: We run their ads in a sandbox swf because they crash all the time. That way if they fail to run, the game loads anyway because the sandbox boots over to the game swf when the ad is done.)
« Last Edit: February 21, 2011, 01:42:56 PM by st33d » Logged
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #1717 on: February 21, 2011, 01:34:08 PM »

We run their ads in a sandbox swf because they crash all the time. That way if they fail to run, the game loads anyway because the sandbox boots over to the game swf when the ad is done.

Classic.  Grin
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
Kekskiller
Guest
« Reply #1718 on: February 21, 2011, 02:12:31 PM »

Code:
bits [(uint)n/(sizeof(T)*8)] &= ~(1 << ((uint)n%(sizeof(T)*8)));

I'm not that happy about it (it sets bit n to 0 in an array with N variables of type T as bit storage), but for having lots of bits in one place, this does work quite ok. I'd love to have some kind of quotient-with-remainder function to avoid such a doubled division. Maybe there is way to do this better, maybe I totally overlooked it. I though about iterating it directly, but I guess that'd be slower.
Logged
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #1719 on: February 21, 2011, 02:44:03 PM »

std::bitset maybe?
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
Pages: 1 ... 84 85 [86] 87 88 ... 295
Print
Jump to:  

Theme orange-lt created by panic