Problems with Qt Creator application using Csound

classic Classic list List threaded Threaded
33 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problems with Qt Creator application using Csound

cuatrocuatros
Hello all!

This is the repository of my Qt Creator Project using Csound (I'm starting it): https://github.com/cuatrocuatros/TFG

First of all, when I want to run it, I have a problem that is showed in the "ProblemLibrary.jpg" file, it is related with the needed library. ¿How can i solve that? You can see where I have the Csound libs on "CsoundLibs-jpg" file. My version of Csound is 0.9.2.1 and QtCreator 3.6.1 (Based on Qt 5.6.0).

Second, what I did is, I created a button "AudioMorphing", I did a slot "on_pushButton1_clicked()" in "mainwindow.cpp" where I playback the .csd file using a csound instance. Is it well located there? Or it goes in another function or file to work? I'm a bit lost.

Thanks for your help.

Ricky
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

Tarmo Johannes-3

Hi,
I will get to it tomorrow.
One thing i noticed in a quick look - i did not see in .pro file that you are including the Csound library? Somwrhing like
-lcsond64 ?
Dont you get any linker errors?

But i will have better look, qt is my cup of tea :)

Tarmo

02.06.2016 21:45 kirjutas kuupäeval "cuatrocuatros" <[hidden email]>:
Hello all!

This is the repository of my Qt Creator Project using Csound (I'm starting
it): https://github.com/cuatrocuatros/TFG

First of all, when I want to run it, I have a problem that is showed in the
"ProblemLibrary.jpg" file, it is related with the needed library. ¿How can i
solve that? You can see where I have the Csound libs on "CsoundLibs-jpg"
file. My version of Csound is 0.9.2.1 and QtCreator 3.6.1 (Based on Qt
5.6.0).

Second, what I did is, I created a button "AudioMorphing", I did a slot
"on_pushButton1_clicked()" in "mainwindow.cpp" where I playback the .csd
file using a csound instance. Is it well located there? Or it goes in
another function or file to work? I'm a bit lost.

Thanks for your help.

Ricky



--
View this message in context: http://csound.1045644.n5.nabble.com/Problems-with-Qt-Creator-application-using-Csound-tp5750019.html
Sent from the Csound - Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

cuatrocuatros
Yeah, I changed that line to:

LIBS +=  "C:\\Program Files\\Csound6_x64\\bin\\csound64.dll"

Now I get another error... https://github.com/cuatrocuatros/TFG/blob/master/FileFormatProblem.jpg, something related with the file format.

Thank you!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

Tarmo Johannes-3
Hi,

I sent you a pull request https://github.com/cuatrocuatros/TFG/pull/1 hopefully I did everything right and you can see my changes.

Your first problem was that you did not add -lcsound64 to LIBS. With -L flag you set the folder of the library (if not where system finds it), with -l the actual library

I tested it on linux and added conditions to the .pro file to set proper paths for linux. I am not sure if win64 condition acutally exists but if it does not work, just get rid of the conditions and leave what is after them.

Otherwise the thing worked but in the way you started Csound now it freezes th UI until Csound is done (ie forever with the initial csd file).
I inserted a loop to the function that does its job in every k-cycle (while (csound->PerformKsmps()==0) and then processes Qt events that might be in the event queue (QCoreApplication::processEvents();). It is  a quick but dirty solution - you should move your Csound work to another thread or use at least CsoundPerformance thread.

Please have a look to the Csound API examples https://github.com/csound/csoundAPI_examples/tree/master/cpp and my various projects in https://github.com/tarmoj

Also make sure that if you  shadow build in QtCrerator, copy the csd and mp3 files to the folder where your binary is built.

Take care!

tarmo

2016-06-03 2:15 GMT+03:00 cuatrocuatros <[hidden email]>:
Yeah, I changed that line to:

LIBS +=  "C:\\Program Files\\Csound6_x64\\bin\\csound64.dll"

Now I get another error...
https://github.com/cuatrocuatros/TFG/blob/master/FileFormatProblem.jpg,
something related with the file format.

Thank you!



--
View this message in context: http://csound.1045644.n5.nabble.com/Problems-with-Qt-Creator-application-using-Csound-tp5750019p5750032.html
Sent from the Csound - Dev mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

cuatrocuatros
First of all, thanks for your help. I tried using your new solutions and yes, now I don't get any error. But the application doesn't start. When I press run, on compile output it appears the same line again and again: https://github.com/cuatrocuatros/TFG/blob/master/SameLine.jpg

I don't know if it's the problem you mentioned ("Otherwise the thing worked but in the way you started Csound now it freezes th UI until Csound is done (ie forever with the initial csd file)") and I have to use CsoundPerfomance thread. I think, for my application, would be so nice to use that function. Can you explain me for what is it used? I'm searching it but I don't understand this phrase very well (taken of an example of the API):

"We use a CsoundPerformanceThread to run Csound in a native thread.  Using a native thread is important to get the best runtime performance for the audio engine.  It is especially important for languages such as Python that do not have true native threads and that use a Global Interpreter Lock. CsoundPerformanceThread has some convenient methods for handling events, but does not have features for doing regular processing at block boundaries.  In general, use CsoundPerformanceThread when the only kinds of communication you are doing with Csound are through events, and not using channels."

If it is of interest, I'm developping a application to launch 2 live shows, using Kinnect, Csound, speakers and a midi keyboard. All these things will be connected to each other and each show will follow an orderly line of events. So I will create 3 profiles in the application (3 initial options to choose what kind of configuration the user wants), one for the first show, another for the second show and the third customized by me.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

cuatrocuatros
¿Can someone help me?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

Tarmo Johannes-3
Hi,

At first the screenshot did not make any sense to me - no obvious error messages, but then I saw your build (The button above Run) is set to "Profile". I think it is a new thing in Qt Creator for Windows and I have no idea what it is for. Please set your build to "Debug" or "Release" and try again.

For the CsoundPerformanceThread thing -  usually I have not used it in Qt projects (at least in recent projects) -  but have put the Csound work to a separate thread -  either using QThread (more porblematic practice) or move an Object doing the Csound business to a separate thread -  see my projects I have referred already many times for examples.

Sorry, but it seems you are quite in the beginning of Qt programming - do you need to program the user interface at all? Perhaps CsoundQt can do all you need -  it is easy to add the buttons and other widgets to widget panel. If you have any functionality missing, you can use python to fulfill that.

Take care!
tarmo

2016-06-14 19:40 GMT+03:00 cuatrocuatros <[hidden email]>:
¿Can someone help me?



--
View this message in context: http://csound.1045644.n5.nabble.com/Problems-with-Qt-Creator-application-using-Csound-tp5750019p5750166.html
Sent from the Csound - Dev mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

cuatrocuatros
It's the same, profile, debug or release should run the application. The only thing I wanna do it is try to compile 1 .csd from Csound into QT creator. Once I can reach that, I can do whatever I want. But for the moment I couldn't... I downloaded the latest QT (4.0.2) , I ran it in debug mode and now I have this error message: https://raw.githubusercontent.com/cuatrocuatros/TFG/master/csound64dll.jpg ... Really, I don't know what it is...

I have to say... That file (csound64.dll) exists inside of "bin"... :(

Waiting for your response. Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

Tarmo Johannes-3

There might be an achitecture conflict. You are using Csound built for 64bit system. Can it be that your compiler (probably mingw) by Qt is 32bit?

In that case I suggest to download Csound 6.06 (cannot look for the link now but search from SourceForge) - the windows installer there is of 32 bit build.

Then of course you nees to change the paths for include files and libraries (will be installed to ProgramFiles(x86) I guess.

Best!

Tarmo

PS next time it is enough if you copy in the email the error message, no need for picture...

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

Michael Gogins-2
If you are compiling with the MIcrosoft compiler you need to link with
csound64.lib not csound64.dll. But csound64.dll needs to be in your
PATH.

Regards,
Mike

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Thu, Jun 16, 2016 at 1:32 PM, Tarmo Johannes <[hidden email]> wrote:

> There might be an achitecture conflict. You are using Csound built for 64bit
> system. Can it be that your compiler (probably mingw) by Qt is 32bit?
>
> In that case I suggest to download Csound 6.06 (cannot look for the link now
> but search from SourceForge) - the windows installer there is of 32 bit
> build.
>
> Then of course you nees to change the paths for include files and libraries
> (will be installed to ProgramFiles(x86) I guess.
>
> Best!
>
> Tarmo
>
> PS next time it is enough if you copy in the email the error message, no
> need for picture...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

cuatrocuatros
Ok! Thanks Tarmo! I'm installing that version, let's see if it goes :D
Btw I'm doing the GUI, screens, etc to develop my application.

Thank you too Michael, but, how do you distinguish csound64.dll from csound64.lib?

I have these lines at the moment:

INCLUDEPATH += "C:\\Program Files\\Csound6_x64\\include\\csound"
LIBS += -L "C:\\Program Files\\Csound6_x64\\bin" # capital L for setting library path
LIBS += -lcsound64 # lowercase l for including the library

How would you write it?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

cuatrocuatros
Ah Tarmo!! I almost got it! Now I could run the app but when I press the button "Sound Morphing" (the one who has to reproduce the csd) appears the following text!!

Starting C:\Users\lagoa\Documents\build-MesaFX-Desktop_Qt_5_7_0_MinGW_32bit-Release\release\MesaFX.exe...
time resolution is 410.546 ns
virtual_keyboard real time MIDI plugin for Csound
0dBFS level = 32768.0
Csound version 6.07 beta (double samples) Dec 24 2015
libsndfile-1.0.25
UnifiedCSD:  leermp3.csd
end of score.   overall amps:      0.0
           overall samples out of range:        0
1 errors in performance
Elapsed time at end of performance: real: 0.000s, CPU: 0.000s
WARNING: could not open library 'C:\Program Files (x86)\Csound6\plugins64\\py.dll' (-1)
Reading CSD failed ... stopping
WARNING: Csound not ready for performance: csoundStart() has not been called



¿What means these warnings?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

Tarmo Johannes-3
Hi,

usually warnings should not stop Csound to start. Can you see if your csd works otherwise (from command line or in CsoundQt? NB! Use the CsoundQt of your 32bit, ie Csound 6.06 intall)

I don't know so much about Windows install, There is somewhere an option in the installer, whether to install Csound with python functionalities or not. If you do, you need to install also python separately. Also tere might be again a 32bit-64bit conflict somewhere...

But once again, Csound should work also in spite of this warning. Can you try to use this very simple test.csd (makes a beep):

<CsoundSynthesizer>

<CsOptions>

-odac -d

</CsOptions>

<CsInstruments>


sr = 44100

ksmps = 32

nchnls = 2

0dbfs = 1


instr 1

out poscil(0.1,440)

endin



</CsInstruments>

<CsScore>

i1 0 3

</CsScore>

</CsoundSynthesizer>



Keep trying! I am sure you will get through it!


You can also try -

If C:\Program Files(x86)\Csound6\plugins64\\py.dll is there, rename or delete if to see if the problem goes away.


tarmo








2016-06-17 2:48 GMT+03:00 cuatrocuatros <[hidden email]>:
Ah Tarmo!! I almost got it! Now I could run the app but when I press the
button "Sound Morphing" (the one who has to reproduce the csd) appears the
following text!!

Starting
C:\Users\lagoa\Documents\build-MesaFX-Desktop_Qt_5_7_0_MinGW_32bit-Release\release\MesaFX.exe...
time resolution is 410.546 ns
virtual_keyboard real time MIDI plugin for Csound
0dBFS level = 32768.0
Csound version 6.07 beta (double samples) Dec 24 2015
libsndfile-1.0.25
UnifiedCSD:  leermp3.csd
end of score.              overall amps:      0.0
           overall samples out of range:        0
1 errors in performance
Elapsed time at end of performance: real: 0.000s, CPU: 0.000s
*WARNING: could not open library 'C:\Program Files
(x86)\Csound6\plugins64\\py.dll' (-1)
Reading CSD failed ... stopping
WARNING: Csound not ready for performance: csoundStart() has not been called
*


¿What means these warnings?



--
View this message in context: http://csound.1045644.n5.nabble.com/Problems-with-Qt-Creator-application-using-Csound-tp5750019p5750189.html
Sent from the Csound - Dev mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

cuatrocuatros
Hi again, the installer for Csound 6.06 in SourceForge it's broken: https://sourceforge.net/projects/csound/files/csound6/Csound6.06/ ...  The installer .exe is from Csound 6.07 beta, not Csound 6.06... I think that's wrong on that page. I searched for Csound 6.06 on Internet but I didn't get any .exe to proceed to the installation... ¿Can you help me with the link where I can download it?

P.D.: If it is the link inside of Csound 6.06 (Setup_Csound6_6.07.0beta2.exe) I installed it and it gives me the same error as I showed you before.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

rorywalsh
http://csound.github.io/download.html

Csound has moved from sourceforge to github. 

On 21 June 2016 at 17:56, cuatrocuatros <[hidden email]> wrote:
Hi again, the installer for Csound 6.06 in SourceForge it's broken:
https://sourceforge.net/projects/csound/files/csound6/Csound6.06/ ...  The
installer .exe is from Csound 6.07 beta, not Csound 6.06... I think that's
wrong on that page. I searched for Csound 6.06 on Internet but I didn't get
any .exe to proceed to the installation... ¿Can you help me with the link
where I can download it?

P.D.: If it is the link inside of Csound 6.06
(Setup_Csound6_6.07.0beta2.exe) I installed it and it gives me the same
error as I showed you before.





--
View this message in context: http://csound.1045644.n5.nabble.com/Problems-with-Qt-Creator-application-using-Csound-tp5750019p5750273.html
Sent from the Csound - Dev mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

Tarmo Johannes-3
In reply to this post by cuatrocuatros

Hi,

If it so as I supposed that you need a 32-bit Csound (are you using 32-bit compiler with Qt?), then you need to stick with the version in sourceforge, there is no official 32-bit build for Csound 6.07.

There is nothing wrong with the 6.07 beta installer that you were using, definitely not broken. I have used it for a project build on Windows 7 and built succesffully CsoundQt on it.

I think there is something messed up in your system - it is easy to happen if you install different versions/arhitectures and the problems can be sometimes hard to find.

Did you try the things I suggested in the previous e-mail? Is the csd otherwise working in CsoundQT or from commandline?


I suggest go back some steps, start from scratch and try to build an easy console application based on an example here

https://github.com/csound/csoundAPI_examples/blob/master/cpp/SimpleCsdPlayback.cpp

or other examples from that catalogue.

U have a feeling you need to gather some understanding, how things work, otherwise this thread grows really long :)


You may have a look also at my project  https://github.com/tarmoj/eclick/tree/master/server

I have built it on various platforms, including Windows, based on the same Csound 6.07 beta.

Heads up!

tarmo


21.06.2016 19:56 kirjutas kuupäeval "cuatrocuatros" <[hidden email]>:
Hi again, the installer for Csound 6.06 in SourceForge it's broken:
https://sourceforge.net/projects/csound/files/csound6/Csound6.06/ ...  The
installer .exe is from Csound 6.07 beta, not Csound 6.06... I think that's
wrong on that page. I searched for Csound 6.06 on Internet but I didn't get
any .exe to proceed to the installation... ¿Can you help me with the link
where I can download it?

P.D.: If it is the link inside of Csound 6.06
(Setup_Csound6_6.07.0beta2.exe) I installed it and it gives me the same
error as I showed you before.





--
View this message in context: http://csound.1045644.n5.nabble.com/Problems-with-Qt-Creator-application-using-Csound-tp5750019p5750273.html
Sent from the Csound - Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

cuatrocuatros
This post was updated on .
Hi there! I returned again to continue working on this project as I couldn't finish it last year.

First of all, I did everything you had said to me. I have Csound 32 bit, last version of Qt Creator (32 bit). And I took a look to your examples, of course (https://github.com/csound/csoundAPI_examples/tree/master/cpp).

When I include the Csound code into the C++ code, trying to play a simple tune, it works great:

void MainWindow::on_pushButton1_clicked()
{

    std::string orc = "sr=44100\n\
    ksmps=32\n\
    nchnls=2\n\
    0dbfs=1\n\
    \n\
    instr 1\n\
    aout vco2 0.5, 440\n\
    outs aout, aout\n\
    endin";

    std::string sco = "i1 0 2";


    //create an instance of Csound
    Csound* csound = new Csound();

    //set CsOptions
    csound->SetOption("-odac");

    //compile orc.
    csound->CompileOrc(orc.c_str());

    //compile sco
    csound->ReadScore(sco.c_str());

    //prepare Csound for performance
    csound->Start();

    //perform entire score
    while (csound->PerformKsmps()==0 && !stopNow) { // set stopNow to true (by Stop button?)
                QCoreApplication::processEvents(); // not to freeze UI. Quick solution but bad practice this way. Better - run Csound in another thread
    }

    csound->Stop();
    stopNow = false; // allow restarting
    //free Csound object
    delete csound;
    }


But then, now, I have 2 problems that I bet they are very easy to solve, but I can't. First problem is, when I try to read an mp3, with the last csound code inside C++, I get an error:

void MainWindow::on_pushButton1_clicked()
{

    std::string orc = "sr=44100\n\
    ksmps=32\n\
    nchnls=2\n\
    0dbfs=1\n\
    \n\
    instr 1\n\
    aL, aR mp3in 'mamalover.mp3'\n\
    outs aL, aR\n\
    endin";

    std::string sco = "i1 0 2";


    //create an instance of Csound
    Csound* csound = new Csound();

    //set CsOptions
    csound->SetOption("-odac");

    //compile orc.
    csound->CompileOrc(orc.c_str());

    //compile sco
    csound->ReadScore(sco.c_str());

    //prepare Csound for performance
    csound->Start();

    //perform entire score
    while (csound->PerformKsmps()==0 && !stopNow) { // set stopNow to true (by Stop button?)
                QCoreApplication::processEvents(); // not to freeze UI. Quick solution but bad practice this way. Better - run Csound in another thread
    }

    csound->Stop();
    stopNow = false; // allow restarting
    //free Csound object
    delete csound;
    }




Error:

error: syntax error, unexpected T_IDENT, expecting NEWLINE or ','  (token "mp3") line 7:
>>>    aL,aR mp3in 'mamalover.mp3

...

Stopping on parser failure
 - note deleted. instr 1(200) undefined


First question: Can I read a mp3 with the csound code inside C++?


Second problem is, when I try to read the .csd from qt creator, it doesn't work. I named it lol.csd and it has the same csound code as before (very simple, it should work):

void MainWindow::on_pushButton1_clicked()
{
    //Create an instance of Csound
        Csound* csound = new Csound();

        //compile instance of csound.
        csound->Compile("lol.csd");

        //prepare Csound for performance
        csound->Start();

        while (csound->PerformKsmps()==0 && !stopNow) { // set stopNow to true (by Stop button?)
            QCoreApplication::processEvents(); // not to freeze UI. Quick solution but bad practice this way. Better - run Csound in another thread
        }

        //perform entire score
        //csound->Perform();
        csound->Stop();
        stopNow = false; // allow restarting
        //free Csound object
        delete csound;

}


What I get on console is the following info:

virtual_keyboard real time MIDI plugin for Csound
0dBFS level = 32768.0
Csound version 6.07 beta (double samples) Dec 24 2015
libsndfile-1.0.25
UnifiedCSD:  lol.csd
rtaudio: PortAudio module enabled ...
using callback interface
rtmidi: PortMIDI module enabled
--Csound version 6.07 beta (double samples) Dec 24 2015
graphics suppressed, ascii substituted
0dBFS level = 32768.0
orch now loaded
audio buffered in 4096 sample-frame blocks
writing 8192-byte blks of shorts to test.wav (WAV)
SECTION 1:
Reading CSD failed ... stopping


As you can see, I get the error reading the CSD... I searched a lot but I can't find the solution.


If someone could help me I would be very pleased. Thank you!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

jpff
Use " not ' in filename,?

Sent from TypeApp
On 21 Feb 2017, at 00:29, cuatrocuatros <[hidden email]> wrote:
Hi there! I returned again to continue working with this project as I
couldn't finish it last year.

First of all, I did everything you had said to me. I have Csound 32 bit,
last version of Qt Creator (32 bit). And I took a look to your examples, of
course (https://github.com/csound/csoundAPI_examples/tree/master/cpp).

When I include the Csound code into the C++ code, trying to play a simple
tune, it works great:

/void MainWindow::on_pushButton1_clicked()
{

std::string orc = "sr=44100\n\
ksmps=32\n\
nchnls=2\n\
0dbfs=1\n\
\n\
instr 1\n\
*aout vco2 0.5, 440\n\*
*outs aout, aout\n\*
endin";

std::string sco = "i1 0 2";


//create an instance of Csound
Csound* csound = new Csound();

//set CsOptions
csound->SetOption("-odac");

//compile orc.
csound->CompileOrc(orc.c_str());

//compile sco
csound->ReadScore(sco.c_str());

//prepare Csound for performance
csound->Start();

//perform entire score
while (csound->PerformKsmps()==0 && !stopNow) { // set stopNow to true
(by Stop button?)
QCoreApplication::processEvents(); // not to freeze UI.
Quick solution but bad practice this way. Better - run Csound in another
thread
}

csound->Stop();
stopNow = false; // allow restarting
//free Csound object
delete csound;
}/

But then, now, I have 2 problems that I bet they are very easy to solve, but
I can't. First problem is, when I try to read an mp3, with the last csound
code inside C++, I get an error:

/void MainWindow::on_pushButton1_clicked()
{

std::string orc = "sr=44100\n\
ksmps=32\n\
nchnls=2\n\
0dbfs=1\n\
\n\
instr 1\n\
*aL, aR mp3in 'mamalover.mp3'\n\*
*outs aL, aR\n\*
endin";

std::string sco = "i1 0 2";


//create an instance of Csound
Csound* csound = new Csound();

//set CsOptions
csound->SetOption("-odac");

//compile orc.
csound->CompileOrc(orc.c_str());

//compile sco
csound->ReadScore(sco.c_str());

//prepare Csound for performance
csound->Start();

//perform entire score
while (csound->PerformKsmps()==0 && !stopNow) { // set stopNow to true
(by Stop button?)
QCoreApplication::processEvents(); // not to freeze UI.
Quick solution but bad practice this way. Better - run Csound in another
thread
}

csound->Stop();
stopNow = false; // allow restarting
//free Csound object
delete csound;
}


/

Error:

/error: syntax error, unexpected T_IDENT, expecting NEWLINE or ',' (token
"mp3") line 7:
aL,aR mp3in 'mamalover.mp3

...

Stopping on parser failure
- note deleted. instr 1(200) undefined/

First question: Can I read a mp3 with the csound code inside C++?


Second problem is, when I try to read the .csd from qt creator, it doesn't
work. I named it lol.csd and it has the same csound code as before (very
simple, it should work):

/void MainWindow::on_pushButton1_clicked()
{
//Create an instance of Csound
Csound* csound = new Csound();

//compile instance of csound.
csound->Compile("lol.csd");

//prepare Csound for performance
csound->Start();

while (csound->PerformKsmps()==0 && !stopNow) { // set stopNow to
true (by Stop button?)
QCoreApplication::processEvents(); // not to freeze UI. Quick
solution but bad practice this way. Better - run Csound in another thread
}

//perform entire score
//csound->Perform();
csound->Stop();
stopNow = false; // allow restarting
//free Csound object
delete csound;

}
/

What I get on console is the following info:

/virtual_keyboard real time MIDI plugin for Csound
0dBFS level = 32768.0
Csound version 6.07 beta (double samples) Dec 24 2015
libsndfile-1.0.25
UnifiedCSD: lol.csd
rtaudio: PortAudio module enabled ...
using callback interface
rtmidi: PortMIDI module enabled
--Csound version 6.07 beta (double samples) Dec 24 2015
graphics suppressed, ascii substituted
0dBFS level = 32768.0
orch now loaded
audio buffered in 4096 sample-frame blocks
writing 8192-byte blks of shorts to test.wav (WAV)
SECTION 1:
*Reading CSD failed ... stopping*/

As you can see, I get the error reading the CSD... I searched a lot but I
can't find the solution.


If someone could help me I would be very pleased. Thank you!





--
View this message in context: http://csound.1045644.n5.nabble.com/Problems-with-Qt-Creator-application-using-Csound-tp5750019p5754739.html
Sent from the Csound - Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

Michael Gogins-2
In reply to this post by cuatrocuatros
For the first question, you don't have the mp3in opcodes in your version of Csound.

For the second question, try running lol.csd with standalone Csound first to see if there is a problem with the CSD.

On Feb 21, 2017 11:29 AM, "cuatrocuatros" <[hidden email]> wrote:
Hi there! I returned again to continue working with this project as I
couldn't finish it last year.

First of all, I did everything you had said to me. I have Csound 32 bit,
last version of Qt Creator (32 bit). And I took a look to your examples, of
course (https://github.com/csound/csoundAPI_examples/tree/master/cpp).

When I include the Csound code into the C++ code, trying to play a simple
tune, it works great:

/void MainWindow::on_pushButton1_clicked()
{

    std::string orc = "sr=44100\n\
    ksmps=32\n\
    nchnls=2\n\
    0dbfs=1\n\
    \n\
    instr 1\n\
    *aout vco2 0.5, 440\n\*
    *outs aout, aout\n\*
    endin";

    std::string sco = "i1 0 2";


    //create an instance of Csound
    Csound* csound = new Csound();

    //set CsOptions
    csound->SetOption("-odac");

    //compile orc.
    csound->CompileOrc(orc.c_str());

    //compile sco
    csound->ReadScore(sco.c_str());

    //prepare Csound for performance
    csound->Start();

    //perform entire score
    while (csound->PerformKsmps()==0 && !stopNow) { // set stopNow to true
(by Stop button?)
                QCoreApplication::processEvents(); // not to freeze UI.
Quick solution but bad practice this way. Better - run Csound in another
thread
    }

    csound->Stop();
    stopNow = false; // allow restarting
    //free Csound object
    delete csound;
    }/

But then, now, I have 2 problems that I bet they are very easy to solve, but
I can't. First problem is, when I try to read an mp3, with the last csound
code inside C++, I get an error:

/void MainWindow::on_pushButton1_clicked()
{

    std::string orc = "sr=44100\n\
    ksmps=32\n\
    nchnls=2\n\
    0dbfs=1\n\
    \n\
    instr 1\n\
    *aL, aR mp3in 'mamalover.mp3'\n\*
    *outs aL, aR\n\*
    endin";

    std::string sco = "i1 0 2";


    //create an instance of Csound
    Csound* csound = new Csound();

    //set CsOptions
    csound->SetOption("-odac");

    //compile orc.
    csound->CompileOrc(orc.c_str());

    //compile sco
    csound->ReadScore(sco.c_str());

    //prepare Csound for performance
    csound->Start();

    //perform entire score
    while (csound->PerformKsmps()==0 && !stopNow) { // set stopNow to true
(by Stop button?)
                QCoreApplication::processEvents(); // not to freeze UI.
Quick solution but bad practice this way. Better - run Csound in another
thread
    }

    csound->Stop();
    stopNow = false; // allow restarting
    //free Csound object
    delete csound;
    }


/

Error:

/error: syntax error, unexpected T_IDENT, expecting NEWLINE or ','  (token
"mp3") line 7:
>>>    aL,aR mp3in 'mamalover.mp3

...

Stopping on parser failure
 - note deleted. instr 1(200) undefined/

First question: Can I read a mp3 with the csound code inside C++?


Second problem is, when I try to read the .csd from qt creator, it doesn't
work. I named it lol.csd and it has the same csound code as before (very
simple, it should work):

/void MainWindow::on_pushButton1_clicked()
{
    //Create an instance of Csound
        Csound* csound = new Csound();

        //compile instance of csound.
        csound->Compile("lol.csd");

        //prepare Csound for performance
        csound->Start();

        while (csound->PerformKsmps()==0 && !stopNow) { // set stopNow to
true (by Stop button?)
            QCoreApplication::processEvents(); // not to freeze UI. Quick
solution but bad practice this way. Better - run Csound in another thread
        }

        //perform entire score
        //csound->Perform();
        csound->Stop();
        stopNow = false; // allow restarting
        //free Csound object
        delete csound;

}
/

What I get on console is the following info:

/virtual_keyboard real time MIDI plugin for Csound
0dBFS level = 32768.0
Csound version 6.07 beta (double samples) Dec 24 2015
libsndfile-1.0.25
UnifiedCSD:  lol.csd
rtaudio: PortAudio module enabled ...
using callback interface
rtmidi: PortMIDI module enabled
--Csound version 6.07 beta (double samples) Dec 24 2015
graphics suppressed, ascii substituted
0dBFS level = 32768.0
orch now loaded
audio buffered in 4096 sample-frame blocks
writing 8192-byte blks of shorts to test.wav (WAV)
SECTION 1:
*Reading CSD failed ... stopping*/

As you can see, I get the error reading the CSD... I searched a lot but I
can't find the solution.


If someone could help me I would be very pleased. Thank you!





--
View this message in context: http://csound.1045644.n5.nabble.com/Problems-with-Qt-Creator-application-using-Csound-tp5750019p5754739.html
Sent from the Csound - Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Problems with Qt Creator application using Csound

cuatrocuatros
I tried and it works, running the csd with CsoundQt.
12
Loading...