Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
GeneralDirectX C# - creating a button Pin
2hdass5-Mar-08 10:12
2hdass5-Mar-08 10:12 
GeneralManage SQLServer C# Pin
half-life5-Mar-08 9:56
half-life5-Mar-08 9:56 
GeneralRe: Manage SQLServer C# Pin
Christian Graus5-Mar-08 10:08
protectorChristian Graus5-Mar-08 10:08 
GeneralRe: Manage SQLServer C# Pin
half-life5-Mar-08 10:14
half-life5-Mar-08 10:14 
GeneralRe: Manage SQLServer C# Pin
Christian Graus5-Mar-08 11:00
protectorChristian Graus5-Mar-08 11:00 
GeneralRe: Manage SQLServer C# Pin
half-life5-Mar-08 11:04
half-life5-Mar-08 11:04 
GeneralRe: Manage SQLServer C# Pin
Tobias Schoenig5-Mar-08 21:25
Tobias Schoenig5-Mar-08 21:25 
GeneralPlaying a file using MCI Pin
Johan Martensson5-Mar-08 9:40
Johan Martensson5-Mar-08 9:40 
I have a small form for trying to record but I can't get it to work properly.

I have the code below and I can record and play the created file in this application and other media players. The code creates a 8bit 11kHz mono.

The problem is when I try to use the "set" parameters, any of them, then I can only play it back in this application, not with any other players.

Am I doing something wrong?

using Microsoft.VisualBasic.Devices;<br />
using Microsoft.VisualBasic;<br />
using System.Runtime.InteropServices;<br />
using System.Windows.Forms;<br />
<br />
namespace Recorder<br />
{<br />
    public partial class Form1 : Form<br />
    {<br />
        [DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]<br />
        private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);<br />
        <br />
        public Form1()<br />
        {<br />
            InitializeComponent();<br />
        }<br />
<br />
        private void buttRecord_Click(object sender, System.EventArgs e)<br />
        {<br />
            // record from microphone<br />
            mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);<br />
<br />
            mciSendString("format tag pcm", "", 0, 0);<br />
            //mciSendString("set recsound bitspersample 8", "", 0, 0);<br />
            //mciSendString("set recsound samplespersec 32000", "", 0, 0);<br />
            mciSendString("set recsound channels 2", "", 0, 0);<br />
<br />
            mciSendString("record recsound", "", 0, 0);<br />
        }<br />
<br />
        private void buttSaveStop_Click(object sender, System.EventArgs e)<br />
        {<br />
            // stop and save<br />
            mciSendString("save recsound c:\\record.wav", "", 0, 0);<br />
            mciSendString("close recsound ", "", 0, 0);<br />
            Computer c = new Computer();<br />
            c.Audio.Stop();<br />
        }<br />
<br />
        private void buttPlay_Click(object sender, System.EventArgs e)<br />
        {<br />
            Computer computer = new Computer();<br />
            computer.Audio.Play("c:\\record.wav", AudioPlayMode.Background);<br />
        }<br />
    }<br />
}


http://johanmartensson.se - Home of MPEG4Watcher

GeneralHelp needed regarding MSI Pin
robustm5-Mar-08 9:34
robustm5-Mar-08 9:34 
GeneralRe: Help needed regarding MSI Pin
Christian Graus5-Mar-08 10:13
protectorChristian Graus5-Mar-08 10:13 
QuestionRun with the windows Pin
Knowledgestudent5-Mar-08 9:09
Knowledgestudent5-Mar-08 9:09 
GeneralRe: Run with the windows Pin
Pete O'Hanlon5-Mar-08 9:40
mvePete O'Hanlon5-Mar-08 9:40 
QuestionRe: Run with the windows Pin
Knowledgestudent5-Mar-08 11:19
Knowledgestudent5-Mar-08 11:19 
GeneralRe: Run with the windows Pin
Ravi Bhavnani5-Mar-08 18:47
professionalRavi Bhavnani5-Mar-08 18:47 
QuestionRe: Run with the windows Pin
Knowledgestudent9-Mar-08 11:13
Knowledgestudent9-Mar-08 11:13 
QuestionSystemParametersInfo SPI_SETWORKAREA Pin
chrsarly045-Mar-08 8:48
chrsarly045-Mar-08 8:48 
GeneralApplication Issue with Access and ReportViewer Pin
rwinte5-Mar-08 8:40
rwinte5-Mar-08 8:40 
GeneralMVP Pattern Pin
Quang Tran Minh5-Mar-08 6:29
Quang Tran Minh5-Mar-08 6:29 
GeneralRe: MVP Pattern Pin
led mike5-Mar-08 6:38
led mike5-Mar-08 6:38 
GeneralRe: MVP Pattern [modified] Pin
papadimitriou5-Mar-08 8:47
papadimitriou5-Mar-08 8:47 
GeneralRe: MVP Pattern Pin
led mike5-Mar-08 8:56
led mike5-Mar-08 8:56 
GeneralRe: MVP Pattern Pin
Quang Tran Minh5-Mar-08 11:11
Quang Tran Minh5-Mar-08 11:11 
GeneralRe: MVP Pattern Pin
led mike5-Mar-08 11:18
led mike5-Mar-08 11:18 
QuestionAvoid duplicates in adding records in MySQL db Pin
baranils5-Mar-08 5:56
baranils5-Mar-08 5:56 
GeneralRe: Avoid duplicates in adding records in MySQL db Pin
led mike5-Mar-08 6:02
led mike5-Mar-08 6:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.