Audio in Visual Studio C#

Is it possible to insert audio into visual studio??

Page 1 of 1

13 Replies - 5863 Views - Last Post: 13 April 2010 - 05:09 PM Rate Topic: -----

#1 toff182  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 08-December 08

Audio in Visual Studio C#

Posted 13 April 2010 - 05:15 AM

Hi,

I was wondering if it is possible to insert audio (vocal audio) into visual studio??

I want to insert a voice when a button is clicked on my application. Are there any tutorials avaible to do this as I can't seem to find any? All the tutorials I find are in reference to volume settings etc.

Thanks in advance,

:)

Is This A Good Question/Topic? 0
  • +

Replies To: Audio in Visual Studio C#

#2 Skaggles  Icon User is offline

  • THE PEN IS MIGHTIER
  • member icon





Reputation: 251
  • View blog
  • Posts: 640
  • Joined: 01-March 09

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 05:44 AM

This tutorial on DIC might be of help: http://www.dreaminco...-your-software/
Was This Post Helpful? 1
  • +
  • -

#3 Yakyb  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 21
  • Joined: 04-June 08

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 08:23 AM

also what Gui are you refering to?

Winforms WPF Silverlight ASP.net
Was This Post Helpful? 0
  • +
  • -

#4 toff182  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 08-December 08

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 09:34 AM

I'm using .Net.

I have got it working now after I followed the tutorial. Thanks very much! :)
Was This Post Helpful? 0
  • +
  • -

#5 toff182  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 08-December 08

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 09:37 AM

Hi

I have recently implemented audio into my application but I want it to play different audio when data is entered into a textbox.

For example, when a number is entered into a text box it displays a corresponding image to that item.

Here is what I have tried so far, but I'm having no joy with it.

if ((code = 50001))
                SoundPlayer SystemVoice = new SoundPlayer(Resource1.Beans);
                SystemVoice.Play();




The error I get is - Embedded statement cannot be a declaration or labeled statement

Thanks in advance to anyone who can help!
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 09:39 AM

Topics merged, since both involve sound in your application there was no need to open a 2nd thread :)
Was This Post Helpful? 0
  • +
  • -

#7 toff182  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 08-December 08

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 11:34 AM

Does anyone have any ideas??
Was This Post Helpful? 0
  • +
  • -

#8 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 11:58 AM

toff182 slow down man, show some patience. This was just started a few hours ago, it can take some time to get a response as everyone here are volunteers and have jobs, families, school and such

Also, you're probably going to need to show more than 2 or 3 lines, it's quite possible the error is being caused above those lines and not being generated until it reaches that point

One more thing to try

SoundPlayer SystemVoice;
if ((code = 50001))
                SystemVoice = new SoundPlayer(Resource1.Beans);
                SystemVoice.Play();



Nevermind, you're in an if statement and trying to do 2 lines of code without braces. Change to this and try

SoundPlayer SystemVoice;
if ((code = 50001))
{
     SystemVoice = new SoundPlayer(Resource1.Beans);
     SystemVoice.Play();
}



Here's some more information on that error
Was This Post Helpful? 1
  • +
  • -

#9 toff182  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 08-December 08

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 12:02 PM

it keeps coming back with the error - Cannot implicitly convert type 'int' to 'string'
Was This Post Helpful? 0
  • +
  • -

#10 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 12:04 PM

Ok, as stated before what I posted will get rid of your initial error, for the 2nd error we need to see more code, how variables are declared, how they're set, etc.
Was This Post Helpful? 1
  • +
  • -

#11 toff182  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 08-December 08

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 12:26 PM

Ok so I now have this code and I'm only getting warnings not errors, so I take it I'm getting somewhere with this.....


SoundPlayer SystemVoice;
            int Beanscode = 50001;

            if(code is int)           
                
{
     SystemVoice = new SoundPlayer(Resource1.Beans);
     SystemVoice.Play();
}


also

code = txtScan.text;

Was This Post Helpful? 0
  • +
  • -

#12 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 12:36 PM

You have this line

 if(code is int) 



But code is not declared anywhere (You declared Beanscode not code). And with this line

code = txtScan.text;



Anything coming from a TextBox is considered a string by default so you're going to have to convert it to an integer value

code = Convert.ToInt32(txtScan.text);


Was This Post Helpful? 1
  • +
  • -

#13 toff182  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 08-December 08

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 03:15 PM

Ok I;ve been trying for hours now and still can't seem to get it working.

I have tried converting both variables and it just wont work....

here is my code so far....


            int beansCode = 50001;
            string barcode;
            barcode = Convert.ToInt32(txtScan.Text);
            

            SoundPlayer SystemVoice;
            //if (code = beansCode)
            if (barcode = beansCode)
            {
                //if (beansCode = true)
                SystemVoice = new SoundPlayer(Resource1.Beans);
                SystemVoice.Play();
            }
             


Was This Post Helpful? 0
  • +
  • -

#14 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Audio in Visual Studio C#

Posted 13 April 2010 - 05:09 PM

Once again, you're trying to compare a string with an int, that cannot happen. See this

string barcode;

//THIS IS GOING TO CAUSE AN ERROR!
barcode = Convert.ToInt32(txtScan.Text);



You have declared barcode as string so you cannot assign it an int value. Then here you're trying to compare the string to an int

if (barcode = beansCode)



So, try this

int beansCode = 50001;
int barcode = Convert.ToInt32(txtScan.Text);            

SoundPlayer SystemVoice;
//if (code = beansCode)
if (barcode = beansCode)
{
     //if (beansCode = true)
     SystemVoice = new SoundPlayer(Resource1.Beans);
     SystemVoice.Play();
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1