Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Beep manually done function

removed content do to leeching.
have this generate wave code for wave class i made ... its much easy (with win os) to work with wav files then mp3
(Jul 19, 2015 09:32 PM)Only3 Wrote:  have this generate wave code for wave class i made ... its much easy (with win os) to work with wav files then mp3

Idk about that, I only know I had to read way to much shit about wav files to make this haha :P but I wouldn't wonder if mp3 is more complicated.
Nice work, you can change the volume of the beep function in "system sound".
(Jul 19, 2015 10:09 PM)Kinepak Wrote:  Nice work, you can change the volume of the beep function in "system sound".
Thanks, yea I know, like I wrote
Quote:and doesn't let you adjust the volume but just uses what your system sound volume is set at.

Adjusting the system sounds volume programatical is quite nasty since there's no direct API for it, and it also affect other software playing sounds using the system sounds volume.
I cannot seem to get this working, what are some example values I should use. I am using 100 for volume, 250 for frequency and 60 for duration.
[Image: GvQ0BkR.jpg]
(Jul 20, 2015 12:14 AM)Jordan "ESEA" Belfort Wrote:  I cannot seem to get this working, what are some example values I should use. I am using 100 for volume, 250 for frequency and 60 for duration.

wierd, cause it works perfect for me with those vals:
Beep(100.0F, 250.0F, 60.0F)
C# version if you want to add it to OP,
I get the feeling I have mistaken something so feel free to scan over it and fix.

PHP Code

<?php 
private static bool Beep(double Volume, double Frequency, double Duration)
{
      try
      {
      
double Amplitude = Volume * 1.27;
      
double A = ((Amplitude * (System.Math.Pow(2, 15))) / 1000) - 1;
      
double DeltaFT = 2 * System.Math.PI * Frequency / 8000;

      
double Samples = 441 * (Duration / 100);
      
int Bytes = System.Convert.ToInt32(Samples) * 4;
      
int[] Hdr = new int[] { 0x46464952, 36 + Bytes, 0x45564157, 0x20746D66, 16, 0x20001, 8000, 176400, 0x100004, 0x61746164, Bytes };

      
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(44 + Bytes))
      {
            
using (System.IO.BinaryWriter binaryWriter = new System.IO.BinaryWriter(memoryStream))
            {
            for (
int i = 0; i < Hdr.Length; i++)
            
binaryWriter.Write(Hdr[i]);

            for (
int T = 0; T < System.Convert.ToInt32(Samples); T++)
            {
            
short Sample = System.Convert.ToInt16(A * System.Math.Sin(DeltaFT * T));
            
binaryWriter.Write(Sample);
            
binaryWriter.Write(Sample);
            }
            
binaryWriter.Flush();
            
memoryStream.Seek(0, System.IO.SeekOrigin.Begin);

            
using (System.Media.SoundPlayer SP = new System.Media.SoundPlayer(memoryStream))
            
SP.PlaySync();
             }
      }
      }
      catch
      {
      return 
false;
      }
      return 
true;
} 
Skype: happy.cbb
0x38E6A0912657E
Haha wow I'm impressed man, I would never have the patience to do something like this! I'll save this snippet if I'll ever need anything like it! Thanks!
(Jul 20, 2015 12:44 AM)Menalix Wrote:  wierd, cause it works perfect for me with those vals:
Beep(100.0F, 250.0F, 60.0F)

I have it working correctly now, I had an error with my thread.
[Image: GvQ0BkR.jpg]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by _redbaron_Jun 14, 2024 04:56 PM 16 668 Jun 14, 2024 04:56 PM
Last Post: secret_code
[C] by FhackMar 2, 2022 03:52 AM 4 306 Mar 2, 2022 03:52 AM
Last Post: Fhack
[Python] by Beginner1234Nov 11, 2021 03:54 AM 2 141 Nov 11, 2021 03:54 AM
Last Post: 3phase