Important alert: (current site time 7/16/2013 4:08:48 AM EDT)
 

VB icon

Record sound CD (track) to WAV file.

Email
Submitted on: 6/14/1999
By: Damjan 
Level: Not Given
User Rating: By 102 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 32482
 
     Record sound from CD (Track1, Track2...) to a WAV file.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Record sound CD (track) to WAV file.
' Description:Record sound from CD (Track1, Track2...) to a WAV file.
' By: Damjan
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2091&lngWId=1'for details.'**************************************

'This control use MCI to control CD
Public Sub RecordWave(TrackNum As Integer, Filename As String)
' TrackNum: track to record
' Filename: file to save wave as
On Local Error Resume Next
Dim i As Long
Dim RS As String
Dim cb As Long
Dim t
RS = Space$(128)
i = mciSendString("stop cdaudio", RS, 128, cb)
i = mciSendString("close cdaudio", RS, 128, cb)
Kill Filename
RS = Space$(128)
i = mciSendString("status cdaudio position track " & TrackNum, RS, 128, cb)
i = mciSendString("open cdaudio", RS, 128, cb)
i = mciSendString("set cdaudio time format milliseconds", RS, 128, cb)
i = mciSendString("play cdaudio", RS, 128, cb)
i = mciSendString("open new type waveaudio alias capture", RS, 128, cb)
i = mciSendString("record capture", RS, 128, cb)
t# = Timer + 1: Do Until Timer > t#: DoEvents: Loop
i = mciSendString("save capture " & Filename, RS, 128, cb)
i = mciSendString("stop cdaudio", RS, 128, cb)
i = mciSendString("close cdaudio", RS, 128, cb)
End Sub


Other 9 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

6/15/1999 7:51:00 PMChris Wells

I am new to sound recording and the MCI control and I was wondering if you could explain how the code works. Thanks.
(If this comment was disrespectful, please report it.)

 
6/27/1999 8:29:00 PMKenneth

Actually, i am looking for capturing voice using microphone and storing it in .wav format
Any help/suggestion/codes ?
Thanks
(If this comment was disrespectful, please report it.)

 
7/3/1999 6:46:00 AMJohn

I need to mciSendString declaration
(If this comment was disrespectful, please report it.)

 
7/4/1999 3:28:00 AMViren

GreatJob!I was looking for such a code! thanks !!
(If this comment was disrespectful, please report it.)

 
7/4/1999 1:43:00 PMGeezus

The wav file gets created, but it's 0 bytes..anyone having similiar problems?
(If this comment was disrespectful, please report it.)

 
7/5/1999 8:15:00 PMNick

I'm getting it at 44bytes and it's not saving any of the track.
(If this comment was disrespectful, please report it.)

 
7/6/1999 6:19:00 AMTigger

Well my setup cant find the class .dll 'mciSendString'
What ????


(If this comment was disrespectful, please report it.)

 
7/7/1999 9:01:00 PMGeezus

ok...i'm getting maybe 2 seconds of the track
then it cuts off...anyone fixed this yet?
(If this comment was disrespectful, please report it.)

 
7/7/1999 9:39:00 PMNate

Man this process is slow. Does anybody have a more efficent way of ripping a cd other than catching whatever goes through the mci? Like just transfering sectors over from the cd and saving it as a .wav file???
(If this comment was disrespectful, please report it.)

 
7/8/1999 5:45:00 PMtotong

hey dude! how do this thing work? how to use this stuff?

tenks!
(If this comment was disrespectful, please report it.)

 
7/10/1999 5:33:00 PMRichard Burns

Problem Solved: Change This Line From,
t# = Timer + 1
To:
t# = Timer + (TRACK LENGTH)

Remember The API For Getting The Track Length
(If this comment was disrespectful, please report it.)

 
7/10/1999 5:34:00 PMRichard Burns

You can get the code from:

http://www.tichtechnology.freeserve.co.uk

(If this comment was disrespectful, please report it.)

 
7/10/1999 5:36:00 PMRichard Burns

Does anyone know how to rip a cd using Digital-Audio, eg (AudioGrabber)
(If this comment was disrespectful, please report it.)

 
7/11/1999 9:41:00 AMShaun Rossi

This code doesn't appear to DIRECTLY 'pull' the data trac off the cd-audio disc. It looks like it's recording thru the mixer and audio cable that connects the cd-rom drive to the sound card. This doesn't do a bit extract.... Am I wrong? -Thanks
(If this comment was disrespectful, please report it.)

 
7/12/1999 12:37:00 AMmespa

does any one have something about writing mp3's
(If this comment was disrespectful, please report it.)

 
7/13/1999 10:13:00 PMin need of help

i need help...because i cant get this program to work, it plays 2 seconds of this song and then stops and then doesnt even create a file! can anyone help?

please,
thanks
(If this comment was disrespectful, please report it.)

 
7/20/1999 12:45:00 PMET

????
(If this comment was disrespectful, please report it.)

 
7/22/1999 2:30:00 PM!!!

This program is equivalent to the one submitted on 8/30/98 by jacob alberty.
Jacob should get the award instead!
(If this comment was disrespectful, please report it.)

 
7/24/1999 10:27:00 AMAthurupana

I am a Programmer from Sri lanka.
This is my first access to "http://www.planet-source-code.com/vb/"
I want to know more about visual basic.
thanks for your web site.
(If this comment was disrespectful, please report it.)

 
7/24/1999 1:25:00 PMdead end

if you know how to work this code send me and email please or im me on aim sn:
odeadendo
(If this comment was disrespectful, please report it.)

 
7/25/1999 10:57:00 AMNaresh

How do i use this code
IF YOU CAN HELP ME PLEASE MAIL ME
(If this comment was disrespectful, please report it.)

 
7/26/1999 3:26:00 PMMike Canejo

add this to your Form to make this Fuction work:

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
(If this comment was disrespectful, please report it.)

 
7/28/1999 2:31:00 AMsuperior code

I wonder how the judges of this site determine the superior code for a month - by looking at the description or the code? I don't believe that they have try the programs out!
(If this comment was disrespectful, please report it.)

 
7/28/1999 5:05:00 AMNaRc

Shaun - Corret, this is not a bit, or byte,
ripper such as "AudioGrabber" or NaRc's
MPEG Workshop ;) use. They are created
in C/C++ for speed and since VB cannot
modify a byte directly you wold have to
use an addon or OCX such as "Dialog-Medien
ACD Control (www.dialog-medien.de)" to
implement a byte ripper into a VB program.
(If this comment was disrespectful, please report it.)

 
7/29/1999 11:09:00 AMAnthony

PLEASE HELP (URGENT)- I am new to VB. I am using vb6, so when I copy the code, where do I paste it. Please mail me. Very urgent. Thank you.
(If this comment was disrespectful, please report it.)

 
7/30/1999 9:19:00 AMAsyong Salungga

I'd like to produce a program on CD that will automatically execute whenever the CDROM is placed inside the drive. Any suggestion?
(If this comment was disrespectful, please report it.)

 
7/30/1999 9:23:00 AMLOGIX

THIS CODE stinks, sure it works but you have to fix it first!, How the judges pick these! All you did was make some links to dll files, and u did the WRONG!
(If this comment was disrespectful, please report it.)

 
8/17/1999 10:28:00 AMEtien

Planet-Source-Code Please Zip all of the code instead of just putting it on
a web-page,thanks
(If this comment was disrespectful, please report it.)

 
8/17/1999 7:06:00 PMNeil RAmsbottom

Grrrrr, every peice of code like this creates a file about 19KB long.
Anyone got any comments?
(If this comment was disrespectful, please report it.)

 
8/18/1999 9:16:00 PMWacko

I added that code to a .bas file, now what?
(If this comment was disrespectful, please report it.)

 
8/18/1999 9:24:00 PMWacko

I got mine working but it only records about 2 seconds worth.
(If this comment was disrespectful, please report it.)

 
8/23/1999 2:49:00 PMDashiarD

Are you fool?
This code is best it can be. Do you know what a DLL is used for when you blame this code and his creator?
and for others. First read the comments be4 asking a question - someone may have asked it be4 you. And the others, do NOT be lame. First explore all the secrets of your VB and THEN come here to get code. These aren't for the VERY starters.
(If this comment was disrespectful, please report it.)

 
8/25/1999 9:50:00 PMAl

Like your new format..Keep up the pace.
(If this comment was disrespectful, please report it.)

 
9/3/1999 4:35:00 AMDine

I am trying to work put how to set my CD Rom to rip at 4x it is capable of it and does it with audiograbber, anyone care to enlighten me? Tanks...
(If this comment was disrespectful, please report it.)

 
9/22/1999 5:07:00 AMRich

Asyoung, you can make a cd automatically start up by placing a file called autorun on your cd, not sure the parameters you have to pass this file, been a while since i used it. Look in your VB help for autorun, may be there.
(If this comment was disrespectful, please report it.)

 
10/2/1999 7:57:00 PMexxd

if you are having problem with the .wav file it might be cuz you need to close the capture after your done recording.
i = mciSendString("close capture", 0&, 0, 0)
(If this comment was disrespectful, please report it.)

 
10/4/1999 8:26:00 AMTWEAKER

I need help getting it to work.
So far I coped it to the form (code)
HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
(If this comment was disrespectful, please report it.)

 
10/4/1999 8:42:00 AMTWERKER

SORRY I PUT WRONG E-MAIL
I THINK.
(If this comment was disrespectful, please report it.)

 
10/4/1999 8:44:00 AMTWEAKER

MY E-MAIL IS TWEAKERBM1@AOL
(If this comment was disrespectful, please report it.)

 
10/14/1999 10:09:00 AMmickey maharajh

Does anyone have vb code that can playback a CD, Wav file or MP3 file at 1/2 speed 1/4 speed etc.????
Any help would be greatly appreciated.

my email is wabb60@hotmail.com
Thx

Mickey
(If this comment was disrespectful, please report it.)

 
12/31/1999 11:06:02 PMMouse

ok this code works... at first it didn't, but, when modified it does... all you "Cut And Paste" programmers run to these sights and expect the gracious programmers who dedicate this code to you people to write your programs for you, and if they sent you something wrong, you jump all over them and say they suck... grow up and learn to program before you make pointless comments...and to the programmers dedicating this source, thank you very much for your time... -mouse
(If this comment was disrespectful, please report it.)

 
1/16/2000 8:25:33 PMJeff katz

I Agree Totally... They Shred Me 2 pieces When I Make ONE LITTLE MISTAKE.
Grow Up!
(If this comment was disrespectful, please report it.)

 
10/23/2001 6:54:58 AMGaz

Anyone know how to turn a .wav file into a list of numbers representing the amplitude at each sample - i.e. a text file like sound is stored in unix
(If this comment was disrespectful, please report it.)

 
1/8/2003 3:55:52 AMWouter van Koppen

nouw t werkt niej hoor...
mci nogwat is niet defined
(If this comment was disrespectful, please report it.)

 
7/4/2005 10:32:08 AM

Does anyone have vb code that can
playback a CD, Wav file or MP3 file at
1/2 speed 1/4 speed etc. ?
Any help
would be greatly appreciated.

my
email is
cheol00@hitel.net
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.