How does Visual C++ compare to old school C++?

foozball3000

Executive Member
Joined
Oct 28, 2008
Messages
5,828
In my box of many ambitious projects, is the dream to create a white noise screensaver. If I plan on using Visual C#, I need to use Unsafe Code. So, it's a plausable route.

The other option will be to use C++. But that's where my question comes in.. How does Visual C++ compare to old school C++?
 

greggpb

Expert Member
Joined
Apr 22, 2005
Messages
1,818
It's the same thing.. visual c++ just adds some template's and libaries for interfacing with the OS.

It also depend's what you are going to use for the screen saver if you are gonna use opengl or direct x ? I would stick to visual c++ Ide as you will be able to do things easeir in windows without having to understand all the in's and outs.
 

foozball3000

Executive Member
Joined
Oct 28, 2008
Messages
5,828
It's the same thing.. visual c++ just adds some template's and libaries for interfacing with the OS.

It also depend's what you are going to use for the screen saver if you are gonna use opengl or direct x ? I would stick to visual c++ Ide as you will be able to do things easeir in windows without having to understand all the in's and outs.
I'm planning on rendering the white noise. (Hardcore!) But I still have no clue on how to do it. My original idea of having a bitmap in the memory was way too slow.

C++ or C# ?
I know all about C#, so I'm exploring the possibility of using C++
 

dequadin

Expert Member
Joined
May 9, 2008
Messages
1,434
If you are worried about portability of your code, you should stick to the standard library.

MS has a lot of "Windows Only" C++ functions. You can still use Visual C++ to code either way...

I assume the hardest part is generating the white noise source? I'm sure there are a couple of algorithms out there that can generate "pretty close to the real thing" Gaussian noise.

You could use GDI+ and C#, I don't see why you have to use unsafe code. Direct3D is also an option...
 
Last edited:

sn3rd

Expert Member
Joined
Jan 18, 2008
Messages
4,305
White noise? You should look into the Marsaglia Bray algorithm. It's not all that well documented (I've only ever found one proper paper on the topic), but it is easy enough to understand and implement.

In the limit, it produces a very good approximation to additive white Gaussian noise.

You'll need a fairly good uniform pseudorandom number generator to implement this, as the quality of the AWGN generator will depend on the quality of the uniform PRNG.
 

sn3rd

Expert Member
Joined
Jan 18, 2008
Messages
4,305
OR he could sample some random UHF frequency :)

True...

Or on Linux, he could use /dev/random :p

Edit:
Actually, not true...

He can't use "some random UHF frequency". He needs to use ALL frequencies, as that's what "white" noise is.

:)
 

dequadin

Expert Member
Joined
May 9, 2008
Messages
1,434
True...

Or on Linux, he could use /dev/random :p

Edit:
Actually, not true...

He can't use "some random UHF frequency". He needs to use ALL frequencies, as that's what "white" noise is.

:)

Yes :D But I assume foozball3000 is going for that TV look, so taking the noise on one frequency component of the spectrum is a good approximation (surely?) Then you could alter the frequency you're sampling and get a cool effect, like tuning an old-school TV...

Hmm if linux has /dev/random, does boost have something similar? Anyone know?
 

sn3rd

Expert Member
Joined
Jan 18, 2008
Messages
4,305
Yes :D But I assume foozball3000 is going for that TV look, so taking the noise on one frequency component of the spectrum is a good approximation (surely?) Then you could alter the frequency you're sampling and get a cool effect, like tuning an old-school TV...

Hmm if linux has /dev/random, does boost have something similar? Anyone know?

Well, as you know, simulating true white noise is impossible; it would require an infinite bandwidth. Thus we're always limited to approximating it.

I think it all depends how he wants to display the "white" noise. If he wants the "TV with really bad signal" then it'd be enough to sample the spectrum in the lowest band possible for TV. If he wants the equaliser-type "white" noise display, then it'd be enough to sample in any range of choice and display the Fourier transform...

I love geeking out :)
 

dequadin

Expert Member
Joined
May 9, 2008
Messages
1,434
Well, as you know, simulating true white noise is impossible; it would require an infinite bandwidth. Thus we're always limited to approximating it.

I think it all depends how he wants to display the "white" noise. If he wants the "TV with really bad signal" then it'd be enough to sample the spectrum in the lowest band possible for TV. If he wants the equaliser-type "white" noise display, then it'd be enough to sample in any range of choice and display the Fourier transform...

I love geeking out :)

/me should have spent less time drinking and more time paying attention during class :D

EDIT: I thinkg this is really the way to go. Showing natural white noise, is waaaay cooler than simulating it through code :p
 
Last edited:

sn3rd

Expert Member
Joined
Jan 18, 2008
Messages
4,305
I'm not so sure this is a derailment, foozball3000 likes overly ambitious projects, he just might consider it :)

I'm half expecting a "tell me more about how I could attempt to achieve an infinite bandwidth..." :D
 

ic

MyBroadband
Super Moderator
Joined
Nov 8, 2004
Messages
14,805
In my box of many ambitious projects, is the dream to create a white noise screensaver. If I plan on using Visual C#, I need to use Unsafe Code. So, it's a plausable route.

The other option will be to use C++. But that's where my question comes in.. How does Visual C++ compare to old school C++?
My advice to you is this, if you already know C# well enough, then get a working prototype going using unmanaged C# code, and when you start refining your working prototype seriously consider migrating to C++ for performance and flexibility.

Visual C++ does introduce some Microsoft-specific language extensions, but I seriously doubt that you need to worry about them at this stage, for the most part VC++ is C++. If you're considering porting to other OSes then your problem will be API related and not really C++.
what about black noise ?
Noise has a colour? Julius Mampoera is always able to make a lot of noise and should be just the thing you're looking for.
 

foozball3000

Executive Member
Joined
Oct 28, 2008
Messages
5,828
/starts downloading new vocabulary upgrade... :wtf:

Thanks for the great responses. Now I have a lot of research to do. :D

:love: Google :love:

But I'll first go and look at the Marsaglia Bray algorithm. Then see if I can do the first version in C#. That way, because a lot of this is new to me, I can focus on how it should work and not how to code it.
 

sn3rd

Expert Member
Joined
Jan 18, 2008
Messages
4,305
/starts downloading new vocabulary upgrade... :wtf:

Thanks for the great responses. Now I have a lot of research to do. :D

:love: Google :love:

But I'll first go and look at the Marsaglia Bray algorithm. Then see if I can do the first version in C#. That way, because a lot of this is new to me, I can focus on how it should work and not how to code it.

Once you're generating random numbers, you should test them. Download and install GNU Octave (or use Matlab if you have access to it). You can plot a histogram of, say, 1 000 000 random numbers and it should give you something that looks like this with a mean of 0 and a standard deviation of 1.
 
Top