i get task form my lecturer to open wav file with c (borland C 3.1)....
can you tell me how to do that....
thanks.....
i get task form my lecturer to open wav file with c (borland C 3.1)....
can you tell me how to do that....
thanks.....
Probably not what you want. More information on exactly what you want pleez.Code:FILE * f = fopen("wav_file.wav", "r");
You could use a windows function to do so, but not with Borland C 3.1. At least, I don't think so.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I got task for you to ask your lecturer why he's still teaching with stone-age tools.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Hey guys, i've got a related question here too.. is it possible to play a raw wav using just the standard libraries?? i think BASIC can do that using "beep" or "sound" command i think...
so, is there a way to do that or do i need a whole lot of libraries and custom header files for that?
It is not who I am inside but what I do that defines me.
Hey Mr. Salem, i dont mean any disrespect ok? my teacher also uses "antique" styles like "void main(void)" and compilers like "turbo C by borland". but since ur not from my place, and in no way can understand the situation which led to this little "breach of standards". Im also hesitant to "correct" my teacher in those aspects that you've already mentioned becoz im still learning the language.Originally Posted by Salem
so, please dont judge me (and others like me) too harshly ok? thanks
It is not who I am inside but what I do that defines me.
It's your up-hill struggle, not mine.
What are you going to do when you use a more modern compiler - re-learn the language from scratch - I've done it (sadly), and it sucks.
If you thought learning C was hard, you should try unlearning a bunch of crap.
Lemme guess, your OS is XP and you use Turbo C?
Geez, get with the program, there are at least half a dozen FREE compilers which are readily available which wipe the floor with TC.
Nobody outside your teacher uses that - any job you'll likely get will use something much more up to date.
The only reason I can think of for teaching that old crap is that the teacher knows they don't have a clue about modern ANSI-C so they stick to what they know year after year after year after year after year after year after year after year after year after......
Do you have to wait for them to all die off before you get an upgrade?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
hmmm, i can see your point crystal clear. but as i've said, im still a newbie: meaning i rely on my teacher and some occasional self-studies and helpful hints from the helpful people on the net to learn C. So, what im trying to do is this: learn the basics and the core in programming first, then learn the advanced thingys (differences in versions and OS's, new updates and features) later on. if i try to do both at the same time, i wont be able to master none.
but about my question, which i will re-iterate:
Hey guys, i've got a related question here too.. is it possible to play a raw wav using just the standard libraries?? i think BASIC can do that using "beep" or "sound" command i think...
so, is there a way to do that or do i need a whole lot of libraries and custom header files for that?
It is not who I am inside but what I do that defines me.
Standard C has no notion of sound or sound cards.
Quzah.
Hope is the first step on the road to disappointment.
but can C "receive" a wav stream (from an external source such as streaming on the net) and "write" it as a "filename.wav" file? im talking bout raw wav here, no compressions or codecs whatsoever..
It is not who I am inside but what I do that defines me.
It most certainly can. You'll probably need to open the stream as a pipe (make first character of the filename a vertical bar, i.e. "|").Originally Posted by sangken
And, btw, I agree with you that learning C is different from, and rather more important than, learning some specific implementation or environment.
EDIT: now see what I've done, got all heated about the rubbish written about old compilers and written some rubbish myself about the question.
Rather than the concept of a pipe, which would be appropriate for script languages like perl or korn shell, you are more likely to find what you want as far as reading streamed data if you investigate socket programming.
Last edited by risby; 09-06-2006 at 08:00 AM.
I think it's a trick question, and Tonto's solution is probably correct. He just asks you to open it, right? He doesn't ask you to play it? Unless he does ... could you give the complete task so we can see if this is the case.
You might just have to open a file with fopen(), read every character in it, writing the characters to a new file. See getc(). The sample code in this FAQ might actually be part of what you need:
Just open the file pointer fp, and use putc() instead of putchar() so you can write to a file and not the screen.Code:int c; while ((c = fgetc(fp)) != EOF) { putchar (c); }
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
For your teacher....
Q1: What is ANSI-C?
Q2: Are you teaching ANSI-C?
Q3: Why not when it's industry standard practice?
I assume you're paying money for this course (one way or another), so you should be looking to get some value out of it in return.
> but can C "receive" a wav stream (from an external source such as streaming on the net)
You'll find it very hard to establish a network connection using that fossil compiler. Yet another reason to upgrade.
If you have a WAV file already, then start with http://www.wotsit.org/ to learn about the file format.
Then figure out whatever low-level API you might have to the actual sound card you have, which is compatible with the compiler you have (this won't be easy either).
Then just open the file in binary mode (dead easy), and interpret the data (not so easy) and pass that onto your sound card (dead easy, if you've figured out all the other steps).
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I don't know how it is in Windows, but in linux steps one and two are the easy part (as you can find the wav header information on the web). . . but step three is rough. Maybe Windows has an eaiser interface for sound cards than ALSA?Originally Posted by Salem