🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.pl.comp.lang.csharp
5 messages
5 total messages Started by ratullloch_delthis Fri, 03 Dec 2010 17:54
Example tutorial of Frequency/tone generator in csharp tia sal22
#21865
Author: ratullloch_delthis
Date: Fri, 03 Dec 2010 17:54
5 lines
1228 bytes
Greetings all
I'm trying to find a tutorial that shows me how to make a Frequency/tone generator in Csharp (C#)
Example I would like to have a slider that changes the value of x for the formula y=sin(x) so if the slider is moved
to 440 it would play a 440hz sin wave out the speaker does such a tutorial exist if so can someone post a link to it
tia sal22
Re: Example tutorial of Frequency/tone generator in csharp tia sal22
#21855
Author: Peter Duniho
Date: Fri, 03 Dec 2010 18:32
30 lines
3180 bytes
On 12/3/10 9:54 AM, ratullloch_delthis wrote:
> Greetings all
> I'm trying to find a tutorial that shows me how to make a Frequency/tone generator in Csharp (C#)
> Example I would like to have a slider that changes the value of x for the formula y=sin(x) so if the slider is moved
> to 440 it would play a 440hz sin wave out the speaker does such a tutorial exist if so can someone post a link to it
> tia sal22

Unlike Java (i.e. the previous language for which you asked this exact 
same question), there is no sample-level audio API support in .NET.  The 
closest you can come is to play pre-generated media files (e.g. .wav). 
See, for example, System.Media.SoundPlayer.

While not really directly relevant to this newsgroup, I will mention 
that alternative solutions would involve using the unmanaged Windows API 
to accomplish what you want.  You can use the WinMM, DirectSound, or 
DirectShow APIs to do this.

DirectSound is the most directly applicable and modern API of those 
three, but I'm not sure whether there's already a good managed library 
that supports that API.  I know there's the DirectShow.NET library 
that's been around for awhile, so in spite of it not being specifically 
for audio support, it might be an easier thing to get working.

The DirectSound API is more like the Java API you've already been told 
about (and WinMM isn't much different either), whereas with the 
DirectShow API you would likely wind up writing an audio source filter 
that pushes samples through the filter graph to be rendered by an audio 
renderer.

Pete
Re: Example tutorial of Frequency/tone generator in csharp tia sal22
#21858
Author: Jeff Johnson
Date: Fri, 03 Dec 2010 18:38
25 lines
2469 bytes
"Peter Duniho" <NpOeStPeAdM@NnOwSlPiAnMk.com> wrote in message 
news:lOadnXF-W7heqmTRnZ2dnUVZ_uudnZ2d@posted.palinacquisition...

>> Greetings all
>> I'm trying to find a tutorial that shows me how to make a Frequency/tone 
>> generator in Csharp (C#)
>> Example I would like to have a slider that changes the value of x for the 
>> formula y=sin(x) so if the slider is moved
>> to 440 it would play a 440hz sin wave out the speaker does such a 
>> tutorial exist if so can someone post a link to it
>> tia sal22
>
> Unlike Java (i.e. the previous language for which you asked this exact 
> same question), there is no sample-level audio API support in .NET.  The 
> closest you can come is to play pre-generated media files (e.g. .wav). 
> See, for example, System.Media.SoundPlayer.

I added some audio capability to an app of mine using Bass 
(http://www.un4seen.com/).

"BASS is an audio library for use in Windows and Mac OSX software. Its 
purpose is to provide developers with powerful and efficient sample, stream 
(MP3, MP2, MP1, OGG, WAV, AIFF, custom generated, and more via add-ons), MOD 
music (XM, IT, S3M, MOD, MTM, UMX), MO3 music (MP3/OGG compressed MODs), and 
recording functions." 
Re: Example tutorial of Frequency/tone generator in csharp tia sal22
#21854
Author: Peter Duniho
Date: Fri, 03 Dec 2010 18:48
23 lines
2826 bytes
On 12/3/10 10:38 AM, Jeff Johnson wrote:
> I added some audio capability to an app of mine using Bass
> (http://www.un4seen.com/).
>
> "BASS is an audio library for use in Windows and Mac OSX software. Its
> purpose is to provide developers with powerful and efficient sample, stream
> (MP3, MP2, MP1, OGG, WAV, AIFF, custom generated, and more via add-ons), MOD
> music (XM, IT, S3M, MOD, MTM, UMX), MO3 music (MP3/OGG compressed MODs), and
> recording functions."

Ah, nice.  I don't have any experience with it, but assuming it's a good 
quality library with a nice managed API (I see that while the library 
itself is unmanaged code, there are .NET _and_ Java wrappers available 
from the developer), the licensing terms look very reasonable to me. 
Free for non-commercial use, and flat (and not too pricey) rates for 
various levels of commercial use.

For the single-product license (€950), I figure unless one can implement 
their own similar functionality (e.g. by wrapping DirectSound) in less 
than a couple of days work (10-15 hours at the most), you'd come out 
ahead just paying for the library instead.

Pete
Re: Example tutorial of Frequency/tone generator in csharp tia sal22
#21857
Author: Willem van Rumpt
Date: Fri, 03 Dec 2010 20:08
21 lines
2086 bytes
On 03-Dec-10 18:54, ratullloch_delthis wrote:
> Greetings all
> I'm trying to find a tutorial that shows me how to make a Frequency/tone generator in Csharp (C#)
> Example I would like to have a slider that changes the value of x for the formula y=sin(x) so if the slider is moved
> to 440 it would play a 440hz sin wave out the speaker does such a tutorial exist if so can someone post a link to it
> tia sal22
>

Take a look at NAudio (http://naudio.codeplex.com/), it might offer what 
you need. If you're developing for Silverlight, then, starting from v3 I 
think, MediaElement allows a MediaStreamSource descendant as its source. 
The descendant class is responsible for streaming the data in a format 
known to MediaElement to a stream, in chuncks of generated samples.

There may be lag and buffer issues when building a 
"on-the-fly-immediate-response" kind of application, but in general, it 
works very, very well. I don't have links handy, but google 
MediaStreamSource, and you're bound to find some useful examples.

-- 
Willem van Rumpt
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads