Creating a sound from scratch?

  • Thread starter Danyel Meyer - dialog-it GmbH
  • Start date
D

Danyel Meyer - dialog-it GmbH

Hallo!

I´m trying to find a way to create a sound of a given frequency and duration
using VB.NET and to play it on a PocketPC.
I´ve taken a look at the "remote-control using audio-port"-article on
CodeProject, but as my C# is not quite well... is there an easier way to do
what I´d like to?

Many thanks in advance,

--
Danyel Meyer
-------------------------------------------
dialog-it GmbH
Röllinghäuser Strasse 55a
31061 Alfeld/Leine

Tel +49 (0) 5181 900 814
Fax +49 (0) 5181 900 815
E-Mail danyel.meyer <at> dialog-it.de
 
G

Guest

Not sure why you need to create the sound in code? Would it not be easier to
play a WAV file that has the sound you want?
 
D

Danyel Meyer - dialog-it GmbH

Hi Chris!

I don´t want to play a sound file, just a simple (sine) sound of a frequency
I can adjust, say: Test-tones or something.
When using wave-files I would have about 50 of them, and I don´t really like
the idea of putting 50 files more on the device, that should be possible to
create there.
I hope there is a way for it...

--
Danyel Meyer
-------------------------------------------
dialog-it GmbH
Röllinghäuser Strasse 55a
31061 Alfeld/Leine

Tel +49 (0) 5181 900 814
Fax +49 (0) 5181 900 815
E-Mail danyel.meyer <at> dialog-it.de
 
P

Paul G. Tobey [eMVP]

Have you searched the newsgroups for this sort of thing? I don't think it
was in managed code, but someone did point out a means of generating simple
single-frequency tones in one of the newsgroups. Google has them all
archived. I'd check this one, microsoft.public.windowsce.app.development,
microsoft.public.windowsce.embedded.vc and
microsoft.public.windowsce.platbuilder (or microsoft.public.windowsce.* in
the Google groups advanced search).

Paul T.
 
A

Adam P. Tatusko, MCSD .NET, MCAD .NET, MCDBA, MCSE

Try the following (must have an internal PC speaker for this to work):

namespace MyCompany.MyProject
{
public class Program
{
public static void Main(string[] args)
{
// plays a 888 hertz frequency sound for 2 seconds
Sounds.Play(888, 2000);
}
}

public class Sounds
{
[DllImport("kernel32.dll")]
private static extern bool Beep(int frequency, int duration);

// frequency is in hertz, ranging from 37 to 32,767
// duration is in milliseconds
public static void Play(int frequency, int duration)
{
Console.WriteLine("Playing {0} hertz for {1} milliseconds",
frequency, duration);
Beep(frequency, duration);
Console.ReadLine();
}
}
}
 
A

Adam P. Tatusko, MCSD .NET, MCAD .NET, MCDBA, MCSE

Sorry, the above will only work on the Desktop, not a Pocket PC.
 
C

Chance Hopkins

C

Chance Hopkins

whoops, what I copied and pasted from my code is wrong (I guess I hadn't
used it yet).

the function for the mobile is different:

BOOL WINAPI PlaySound(
LPCSTR pszSound,
HMODULE hmod,
DWORD fdwSound
);



"Adam P. Tatusko, MCSD .NET, MCAD .NET, MCDBA, MCSE, MCSA"
 
D

Danyel Meyer - dialog-it GmbH

Thanks all, but just playing a sound was not the question.

I´ve found a library now at www.zyche.com, (.NET Simple Audio for Pocket
PC), thanks to the google-archives. It´s not exactly what I was looking for,
but worth a try, and works really great!

Further advices on this topic are still welcome ;)

--
Danyel Meyer
-------------------------------------------
dialog-it GmbH
Röllinghäuser Strasse 55a
31061 Alfeld/Leine

Tel +49 (0) 5181 900 814
Fax +49 (0) 5181 900 815
E-Mail danyel.meyer <at> dialog-it.de
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top