1
$\begingroup$

Having had little experience in PHP, I moved to C++ in-order to create a spectrogram, I wanted to create probably the simplest/easiest one for my first project, so easy infact I don't need reading/write to files or add settings to it.

But, as far as I have been learning C++ I was able to manipulate audio file, only to read and write, but the spectrogram works, by reading from a mic and this seems kind of hard to do. I have looked every link in Google, with the word spectogram and C++ in it, but I haven't gotten any useful page.

Now, if I am not mistaken, for the project I am working on, it may be good idea to use JAVA, because I read somewhere that JAVA is better than C++ 1 in a way it manipulates sound, and 2 it is actually easier to learn than C++

So, I wanted to ask here, if JAVA is better for my project, which I will be doing in Windows7?

$\endgroup$

closed as off topic by Jason R, Paul R, Matt L., jonsca, datageist Jun 20 '13 at 10:17

Questions on Signal Processing Stack Exchange are expected to relate to signal processing within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ This question is better off on Stack Overflow. $\endgroup$ – Jason R Jun 19 '13 at 12:42
  • 1
    $\begingroup$ @JasonR I know. I asked it there, and they told me to ask it it. I got even 9 downvotes there. $\endgroup$ – user2487996 Jun 19 '13 at 12:57
  • 3
    $\begingroup$ The downvotes are likely because it's not a well-formed question. There is nothing about Java or C++ that makes one better-suited for audio manipulation. If you want to generate a plot, you're probably going to want an existing library of some kind. These exist for many languages, including C++ and Java. With that said, this isn't really related to signal processing, so I'm guessing this question will be closed also. $\endgroup$ – Jason R Jun 19 '13 at 14:03
  • $\begingroup$ @user2487996 The question itself is off-topic here, but here's a link to C++ source for a spectrogram viewer: relisoft.com/freeware/freq.html $\endgroup$ – datageist Jun 20 '13 at 10:20
6
$\begingroup$

For the first few experiments I would recommend using a scripting language like Matlab or Python. They're much easier to understand and much quicker to write than "lower level programming languages" like C++.

Matlab has a signal processing toolbox and can read and write audio files, do windowing, FFTs etc. as well as a very simple playback mechanism. Basic 2D and 3D-plotting tools are also built right into the language itself.

For Python there is the SciPy library that does all kinds of scientific computing, including wavefile handling, windowing and FFT as well. Plus, there is the Matplotlib that does all of the plotting for you.

In C++, you would have to find a UI toolkit that works for your OS, write a drawing widget to plot stuff in and then fill it with data. Plus, obviously all the memory management; wich will probably become the biggest annoyance and time-sink if you're not experienced in doing it.

To implement live playback and recording I suggest using portaudio, a library written in C. There exists a Matlab .MEX utiliy called PlayRec and there are Python bindings called PyAudio.

From my experience, if you want to use portaudio I'd suggest using Python. Compiling the .mex utility is a huge pain while Python seemed to "just work".

If you manage to get it to work but still want to do it in C++ you can then port the codebase (just a couple of lines in both Matlab or Python) while still using portaudio for the audio input/output.

For a superficial comparison of the different code-complexities you can take a look at some work I wrote last year. Each implementation does the same thing, just in a different language:

$\endgroup$
  • $\begingroup$ Thank for the answer. I was learning C++ for 4 days straight, but changed to Java because, C++ is actually harder with memory management and stuff, so I was looking for an answer which would allow me to choose between the two. whichever is the best. So, do you think I can get the job done easier in python than in java? $\endgroup$ – user2487996 Jun 19 '13 at 16:53
  • 2
    $\begingroup$ Without having tried to do this kind of work in Java I would still say so, yes. Scipy and Numpy are a really stable and well designed foundation to do any kind of scientific computations with. $\endgroup$ – Nils Werner Jun 19 '13 at 18:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.