How to use C++ Audacity source in C?

Building and customizing Audacity from the source code.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
darkingthereturn
Posts: 3
Joined: Fri Apr 15, 2011 5:34 pm
Operating System: Please select

How to use C++ Audacity source in C?

Post by darkingthereturn » Fri Apr 15, 2011 5:36 pm

Hi, i'm writing a C program that takes a wav file in input and process it using Noise Reduction (Removal) from Audacity. However, i've noticed only two files: NoiseRemoval.cpp and NoiseRemoval.h.

Is there a way to use the noise removal function in my C project?
Thank you :)

Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: How to use C++ Audacity source in C?

Post by Edgar » Fri Apr 15, 2011 11:27 pm

C has not been used much in 20 years or so. Why are you sticking with C? Unless your compiler is that old it will compile the .cpp files and c++ code just fine. Give it a try.

darkingthereturn
Posts: 3
Joined: Fri Apr 15, 2011 5:34 pm
Operating System: Please select

Re: How to use C++ Audacity source in C?

Post by darkingthereturn » Sat Apr 16, 2011 12:14 am

I'm using C because I'm a first year university student in computer science and it's the only language i've learned till now... so... thanks anyway.

bgravato
Posts: 2098
Joined: Wed Jan 13, 2010 8:56 pm
Operating System: Linux Debian

Re: How to use C++ Audacity source in C?

Post by bgravato » Sat Apr 16, 2011 2:07 am

Edgar wrote:C has not been used much in 20 years or so.
No? I must be living in the past then :P

I thought that C was probably the most used language still... :)
Include as much details as you can in your post (Audacity version, Operating System, Equipment used, etc).
Please post your question in the appropriate forum (regarding audacity version and operating system).

Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: How to use C++ Audacity source in C?

Post by Edgar » Sat Apr 16, 2011 2:40 pm

What C compiler are you folks using that does not compile C++? C is a sub-set of C++--any C++ compiler will compile C. I find it hard to believe that any school is teaching C only in lieu of C++!

Still, as I said in my first reply, even if the OP wants to stick with C, the Audacity code will compile just fine as C++ code in any modern compiler--and there are lots of very good free modern compilers. Just stick it in your project (getting all the dependencies right is another story), compile and link the new object code in.

bgravato
Posts: 2098
Joined: Wed Jan 13, 2010 8:56 pm
Operating System: Linux Debian

Re: How to use C++ Audacity source in C?

Post by bgravato » Sun Apr 17, 2011 12:16 pm

Yes, he can use C++ code in his C projects, if the compiler he's using supports it (and yes many of the current C/C++ compilers for "normal" computers can do both). But my OT comment was just to point that C is still quite used and useful, specially if you're writing code for small devices. Usually the only compilers available are for assembly and C. I know of many devices to which you can only write code in C and not in C++, but I don't know of any that you can write code in C++, but not in C. Therefore I think that it's more important to learn C first than jumping straight to C++, without knowing C in the first place... But that's my 2 cents :)
Include as much details as you can in your post (Audacity version, Operating System, Equipment used, etc).
Please post your question in the appropriate forum (regarding audacity version and operating system).

Post Reply