Jump to content

Random generator based on noise from sound card ?


Recommended Posts

Hello!

I want to make random number generator based on noise from my sound card !

Maybe will require WMI query for get information from sound card and with this infromation based on sound card noise can be make some algorithm who generate completely random numbers!

Can someone say me how ?

Thanks in advance!

Link to comment
Share on other sites

I attempted to help you out, but so far it isn't working. I wrote this code to record sound for 3 seconds and then make a hash of that file. However, it is coming up with the same hash every time. Maybe my sound card is so good there's no noise being generated. Anyways, here's what I wrote.

#include <Crypt.au3>

If @OSVersion = "Win_XP" Then
    Run("sndrec32 /new /embedding " & @DesktopDir & "soundPW.wav" )
    Sleep(3000)
    Run("sndrec32 /close")
    ProcessClose("sndrec32.exe")
Else
    Run("SoundRecorder /FILE " & @DesktopDir & "soundPW.wav /DURATION 0000:00:03")
EndIf

$hash = _Crypt_HashFile(@DesktopDir & "soundPW.wav", $CALG_SHA1)
FileRecycle(@DesktopDir & "soundPW.wav")
MsgBox(0, "", $hash)
Link to comment
Share on other sites

seems to work fine

#include <Crypt.au3>

soundplay ("C:UsersPublicMusicSample MusicKalimba.mp3" , 0)
Runwait("SoundRecorder /FILE " & @DesktopDir & "soundPW.wav /DURATION 0000:00:03")
soundplay("")
$hash1 = _Crypt_HashFile(@DesktopDir & "soundPW.wav", $CALG_SHA1)
FileDelete(@DesktopDir & "soundPW.wav")

soundplay ("C:UsersPublicMusicSample MusicMaid with the Flaxen Hair.mp3" , 0)
Runwait("SoundRecorder /FILE " & @DesktopDir & "soundPW.wav /DURATION 0000:00:03")
soundplay("")
$hash2 = _Crypt_HashFile(@DesktopDir & "soundPW.wav", $CALG_SHA1)
FileDelete(@DesktopDir & "soundPW.wav")

msgbox (0, '' , $hash1 & @CRLF & $hash2)
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

seems to work fine

#include <Crypt.au3>

soundplay ("C:UsersPublicMusicSample MusicKalimba.mp3" , 0)
Runwait("SoundRecorder /FILE " & @DesktopDir & "soundPW.wav /DURATION 0000:00:03")
soundplay("")
$hash1 = _Crypt_HashFile(@DesktopDir & "soundPW.wav", $CALG_SHA1)
FileDelete(@DesktopDir & "soundPW.wav")

soundplay ("C:UsersPublicMusicSample MusicMaid with the Flaxen Hair.mp3" , 0)
Runwait("SoundRecorder /FILE " & @DesktopDir & "soundPW.wav /DURATION 0000:00:03")
soundplay("")
$hash2 = _Crypt_HashFile(@DesktopDir & "soundPW.wav", $CALG_SHA1)
FileDelete(@DesktopDir & "soundPW.wav")

msgbox (0, '' , $hash1 & @CRLF & $hash2)

This return -1 every time for 2 hashes !

How i can make random number ( not hash ) generator with this example ?

Edited by programings
Link to comment
Share on other sites

It isn't obvious that sampling noise from a sound card will ever generate truly random values. While it may be true that you sample a bit of white or pink noise having fairly good randomness characteristic, it's likely that you're also going to sample mains and other very predictable hum sources having much more peak value. I wouldn't bet my life on that: a good proven PRNG will be far better.

If you insist on a physical source of truly random values, try using a web-based source, like http://www.random.org/ among many others.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...