Chris86 Posted August 15, 2008 Share Posted August 15, 2008 How can I play the X hertz from my speaker? I would like to have something that is equally Beep feature, but it must be played back from the speaker Link to comment Share on other sites More sharing options...
Uriziel01 Posted August 15, 2008 Share Posted August 15, 2008 Look for MIDI UDF on board, but im not quite sure if it allow to play some frequency (in hz) from the speaker. But I wish you good luck in searching Link to comment Share on other sites More sharing options...
BrettF Posted August 15, 2008 Share Posted August 15, 2008 Bass.dll has it covered expandcollapse popupGlobal Const $BASS_SAMPLE_LOOP = 4 Global Const $BASS_SAMPLE_OVER_POS = 0x20000 $Hz = 40 $L = 1000 $A = 32760 $SR = 22000 $Pi = 3.1415 $F = (2 * $Pi * $Hz) / $SR $bass_dll = DllOpen ("Bass.dll") $ret = DllCall($bass_dll, "int", "BASS_Init", "int", -1, _ "int", 44100, _ "int", 0, _ "hwnd", 0, _ "ptr", 0) If Not $ret[0] Then MsgBox(0, "Error", 'Error initializing audio!'); Exit EndIf $HSAMPLE = DllCall ($bass_dll, "dword", "BASS_SampleCreate", "dword", 256, "dword", 28160, "dword", 1, "dword", 1, "dword", $BASS_SAMPLE_LOOP + $BASS_SAMPLE_OVER_POS); // create sample $struct = DllStructCreate ("char[128]") For $i = 0 To 128 $data = ($A * (sin($F * $i))) DllStructSetData ($struct, 1, $data, $i) $ret = DllCall ($bass_dll, "dword", "BASS_SampleSetData", "dword", $HSAMPLE[0], "ptr", DllStructGetPtr ($struct)); // set the sample's data Next $hchan = DllCall ($bass_dll, "dword", "BASS_SampleGetChannel", "dword", $HSAMPLE[0], "int", 1) $ret = DllCall($bass_dll, "int", "BASS_ChannelPlay", "dword", $hchan[0], "int", 0) Sleep (5000) DllCall ($bass_dll, "int", "BASS_SampleStop", "dword", $HSAMPLE[0]) DllCall ($bass_dll, "int", "BOOL BASS_Free") Pretty sure my method of calculation was wayyy off, but I'm sure someone can fix that up Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Uriziel01 Posted August 15, 2008 Share Posted August 15, 2008 Oh, yeah bass.dll ! I have forgothed about it Thx for fixing me Link to comment Share on other sites More sharing options...
BrettF Posted August 15, 2008 Share Posted August 15, 2008 I posted it because it made some sound, but from the bass.dll example, its audibly different.For a 440Hz wave, they had:HSAMPLE sample=BASS_SampleCreate(256, 28160, 1, 1, BASS_SAMPLE_LOOP|BASS_SAMPLE_OVER_POS); // create sample short data[128]; // data buffer int a; for (a=0; a<128; a++) data[a]=(short)(32767.0*sin((double)a*6.283185/64)); // sine wave BASS_SampleSetData(sample, data); // set the sample's dataDifferent :|I got my method from http://www.geocities.com/SiliconValley/Cam...8645/synth.html Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
microera Posted June 24, 2012 Share Posted June 24, 2012 Can anybody make this working? BASS_SampleCreate and then Play with BASS? Pleaseeee for working code....... Link to comment Share on other sites More sharing options...
eukalyptus Posted June 24, 2012 Share Posted June 24, 2012 Here you are: #AutoIt3Wrapper_UseX64=n #include "Bass.au3" Global $nFreq = 440 ; Hz Global Const $pi = ATan(1) * 4 _BASS_Startup() _BASS_Init(0, -1, 44100, 0, "") Global $hSample = _Bass_SampleCreate(88200, 44100, 1, 1, $BASS_SAMPLE_LOOP) Global $tSampleData = DllStructCreate("short[44100]") Global $fTmp = $pi * 2 / (44100 / $nFreq) For $i = 1 To 44100 DllStructSetData($tSampleData, 1, 32767 * Sin($i * $fTmp), $i) Next _Bass_SampleSetData($hSample, DllStructGetPtr($tSampleData)) Global $hChan = _Bass_SampleGetChannel($hSample, 0) _BASS_ChannelSetVolume($hChan, 30) _Bass_ChannelPlay($hChan, 0) Sleep(5000) _Bass_SampleStop($hSample) _BASS_SampleFree($hSample) _BASS_Free() DirectSound UDF Direct2D UDF Link to comment Share on other sites More sharing options...
microera Posted June 24, 2012 Share Posted June 24, 2012 thanks eukalyptus but: compile and run working OK ..... but on my speakers is silence! ? Link to comment Share on other sites More sharing options...
BrewManNH Posted June 24, 2012 Share Posted June 24, 2012 thanks eukalyptus but: compile and run working OK .....but on my speakers is silence! ?That script worked for me, are you sure it wasn't playing and the volume was just too low, because that frequency is hard to hear at a low volume. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
microera Posted June 25, 2012 Share Posted June 25, 2012 I try with sox play dos command: _RunDos("play -n -n synth 1 sine 440 ") and I hear 440Hz .... Link to comment Share on other sites More sharing options...
microera Posted June 25, 2012 Share Posted June 25, 2012 I test on 2 PCs (winXP SP3) and on both not working! Compile and RUN OK ..but nothing hear from speakers.... ? Link to comment Share on other sites More sharing options...
BrewManNH Posted June 25, 2012 Share Posted June 25, 2012 You do have the Bass.dll file and it's located in the script directory correct? BTW, there's no reason to compile the script if all you want to do is test it, you can run it from SciTE by pressing F5 if you're using SciTE. microera 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
microera Posted June 25, 2012 Share Posted June 25, 2012 Nice!! working! I copy bass.dll to working directory and all working! Thanks BrewManNH!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now