473,395 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to play sound in buffer..?

this is my source :$ (tone generator)

how to play sound in outputbuffer?

please help me...teach me detail...:$

using System;
namespace ConsoleApplication4
{

/// <summary>
/// Class1¿¡ ´ëÇÑ ¿ä¾à ¼³¸íÀÔ´Ï´Ù.
/// </summary>
public class Class1
{
public static double fo;
public static double fs;
public static double wo;
public static short Ampl;
public static double m_2cosWo;

public static int MAX_OUTPUT_SAMPLES = 4096;
public static int MAX_VOIE = 2;
public static int MAX_SIZE_SAMPLES = 1;
public static int MAX_SIZE_OUTPUT_BUFFER =
MAX_OUTPUT_SAMPLES*MAX_VOIE*MAX_SIZE_SAMPLES;

public static UInt16 m_WaveOutSampleRate = 16000;
public static int m_NbMaxSamples = MAX_OUTPUT_SAMPLES;
public static UInt16 m_SizeRecord;

public static bool m_Toggle;
public static double[,] OutputBufferR = new
double[2,MAX_OUTPUT_SAMPLES];
public static double[,] OutputBuffer = new
double[2,MAX_OUTPUT_SAMPLES];


/// <summary>
/// ÇØ´ç ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ ÁÖ ÁøÀÔÁ¡ÀÔ´Ï´Ù.
/// </summary>
[STAThread]
static void Main(string[] args)
{

Console.Write("Sample rate : ");
Console.WriteLine(m_NbMaxSamples);
Console.ReadLine();

CSinGenerator();

//
// TODO: ¿©±â¿¡ ÀÀ¿ë ÇÁ·Î±×·¥À» ½ÃÀÛÇÏ´Â Äڵ带 Ãß°¡ÇÕ´Ï´Ù.
//
}

static void SetSinParametres(short A, double freq)
{
Ampl = A;
fo= freq;
}

static void SetInitialConditions()
{

OutputBufferR[1,m_NbMaxSamples-2]= (double) (Ampl * -Math.Sin(wo));
OutputBufferR[1,m_NbMaxSamples-1]= 0;
Console.WriteLine(OutputBufferR[1,m_NbMaxSamples-2]);
Console.WriteLine(OutputBufferR[1,m_NbMaxSamples-1]);
Console.ReadLine();
}

static void ComputeSamples()
{
if (m_Toggle)
{
OutputBufferR[1,0] = (double)(
m_2cosWo*OutputBufferR[0,m_NbMaxSamples-1]-OutputBufferR[0,m_NbMaxSample
s-2]);
OutputBuffer[1,0] = (short)OutputBufferR[1,0];
OutputBufferR[1,1] = (double)(
m_2cosWo*OutputBufferR[1,0]-OutputBufferR[0,m_NbMaxSamples-1]);
OutputBuffer[1,1] = (short)OutputBufferR[1,1];
for (int i = 2; i< m_NbMaxSamples; i++)
{
OutputBufferR[1,i] = (double)(
m_2cosWo*OutputBufferR[1,i-1]-OutputBufferR[1,i-2]);
OutputBuffer[1,i] = (short)OutputBufferR[1,i];
Console.WriteLine(m_2cosWo*OutputBufferR[1,i-1]-OutputBufferR[1,i-2
]);
Console.WriteLine(OutputBufferR[1,i]);
}
}
else
{
OutputBufferR[0,0] = (double)(
m_2cosWo*OutputBufferR[1,m_NbMaxSamples-1]-OutputBufferR[1,m_NbMaxSample
s-2]);
OutputBuffer[0,0] = (short)OutputBufferR[0,0];
OutputBufferR[0,1] = (double)(
m_2cosWo*OutputBufferR[0,0]-OutputBufferR[1,m_NbMaxSamples-1]);
OutputBuffer[0,1] = (short)OutputBufferR[0,1];

for (int i = 2; i< m_NbMaxSamples; i++)
{
/*OutputBufferR[0][i] = (double)(
m_2cosWo*OutputBufferR[0][i-1]-OutputBufferR[0][i-2]);*/
OutputBufferR[0,i] = (double)(
m_2cosWo*OutputBufferR[0,i-1]-OutputBufferR[0,i-2] );

OutputBuffer[0,i] = (short)OutputBufferR[0,i];
}
}
}

public static void CSinGenerator()
{
double pi = 4.0*Math.Atan(1.0);
fo = 440;
fs = m_WaveOutSampleRate;
wo = 2*pi*fo/fs;
Ampl = 10000;
m_2cosWo =2*Math.Cos(wo);

SetInitialConditions();
m_Toggle = false;
ComputeSamples();
m_Toggle = true;
ComputeSamples();
}
}
}
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
0 1828

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: The Road To Utopia | last post by:
Here's one for the trolls...a common jibe from them is setting up audio/video hardware under linux. Ok, true story: at work today, someone asked me if I could tell him why his XP Home would play...
1
by: Ron Provost | last post by:
Hello, I'm developing a piece of software to assist illiteraate adults to learn to read. I'm trying to figure out how, if possible, to make audio playback asynchrnous but still controllable. ...
2
by: NB | last post by:
I've done a thorough search, but could not find any posts If I store a sound file within the mdb, How do I play it (in a form event, for example) I can save it to a temp folder and call the...
22
by: MLH | last post by:
I have some audio help files that play fine from within Access 97 and Access 2.0. Both are running on a Windows XP box. But I do not know what program plays the files. If I click Start, Run and...
25
by: Will Pittenger | last post by:
I have a C# application that I would like to notify the user of events with sound. Is there a way to playback at least the standard sounds? ---------- Will Pittenger E-Mail:...
1
by: JC | last post by:
Hi, I have to play a streaming audio. So in a thread I play audio as follow thread{ //some code for(;;){ //some code waveOutPrepareHeader(hwo, &(whdr), sizeof(WAVEHDR)); waveOutWrite(hwo,...
1
by: Lam | last post by:
how can I play sound file in a .aspx page written in C#? I try to use the code like the following. But whenI call the play function play("sound.wav", this.SND_ASYNC) my computer give out "be"...
3
by: Jared | last post by:
I'm using the first code sample below to play WAV files stored as embedded resources. For some reason I *occasionally* get scratching and crackling. I'm using a couple WAVs that ship with...
5
by: | last post by:
Hello, I am wrtting a program that does some sound effects... the files are stored in a subfolder in the application folder... and I check the existence of the files before calling the method to...
26
by: Jake Barnes | last post by:
I did a search on the newsgroup comp.lang.javascript. I was searching for "how to play a sound with Javascript". I'm somewhat suprised that the majority of entries are from the 1990s, and there are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.