Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to call a mobile through voice modem and play a wave file over it my code is here !! Its not working !!just while looping but no answer or no error! when I resubmit request its detect error "Access to the port 'Com1' is denied"

VB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using NAudio.Wave;
using System.IO.Ports;
using System.Threading;

namespace mearge
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            System.IO.Ports.SerialPort comPort;
            comPort = new System.IO.Ports.SerialPort("Com1",9600, System.IO.Ports.Parity.None, 8, StopBits.One);
            comPort.DtrEnable = true;
            //Switch to Voice Mode
            comPort.Write("AT+FCLASS=8" + System.Convert.ToChar(13).ToString());
            //Call Number
            comPort.Write("ATDT997448***" + System.Convert.ToChar(13).ToString());
            //Enter Voice-Transmission Mode
            comPort.Write("AT+VTX" + System.Convert.ToChar(13).ToString());
            bool MSwitch = false;
            byte[] buffer = new byte[20000];
            FileStream strm = new FileStream(@"D:\943461101.wav", System.IO.FileMode.Open);
            MemoryStream ms = new MemoryStream();
            int count = ms.Read(buffer, 44, buffer.Length - 44);
            BinaryReader rdr = new BinaryReader(strm);
            while (!MSwitch)
            {
                byte[] bt = new byte[1024];
                bt = rdr.ReadBytes(1024);
                if (bt.Length == 0)
                {
                    MSwitch = true;
                    break;
                }
                comPort.Write(bt, 0, bt.Length);
            }
            strm.Close();
            strm.Dispose();


        }
    }
}
Posted
Updated 8-Jul-14 1:25am
v2
Comments
Richard MacCutchan 8-Jul-14 7:44am    
How do you expect the telephone at the far end to know that what you are sending it is the contents of a .wav file?

That will not work at all.

The modem takes digital data and turns it into high pitched tones that can then be turned back into digital data. It does not send the contents of a .wav file as the actual sounds in that file.
 
Share this answer
 
Unless your modem hardware has the capability of playing a WAV file over the modem, you simply can't do it.
 
Share this answer
 
Look here:
Answering machine(TAPI 2.1)[^]
and here:
Transmitting Audio Over a Speakerphone Modem[^]

Or Google for:
play sound through modem
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900