Here's a corrected translation of the VB.NET code, which works for me on full framework:
using System;
using System.IO;
using System.Media;
static class beep
{
public static void Beep(int Amplitude, int Frequency, int Duration)
{
double A = ((Amplitude * Math.Pow(2, 15)) / 1000) - 1;
double DeltaFT = 2 * Math.PI * Frequency / 44100;
int Samples = 441 * Duration / 10;
int Bytes = Samples * 4;
int[] hdr = { 0x46464952, 36 + Bytes, 0x45564157, 0x20746D66, 16, 0x20001, 44100, 176400, 0x100004, 0x61746164, Bytes };
using (MemoryStream MS = new MemoryStream(44 + Bytes))
using (BinaryWriter BW = new BinaryWriter(MS))
{
for (int i = 0; i < hdr.Length; i++)
{
BW.Write(hdr[i]);
}
for (int i = 0; i < Samples; i++)
{
short sample;
sample = Convert.ToInt16(A * Math.Sin(DeltaFT * i));
BW.Write(sample);
BW.Write(sample);
}
BW.Flush();
MS.Seek(0, SeekOrigin.Begin);
using (SoundPlayer SP = new SoundPlayer(MS))
{
SP.Stream = null;
SP.Stream = MS;
SP.PlaySync();
}
}
}
}
Hopefully that should also work on CF. :)