Csound Csound-dev Csound-tekno Search About

[CSOUND-DEV:3088] RE: CSound API with 4.23f07?

Date2003-09-15 17:41
From"gogins@pipeline.com"
Subject[CSOUND-DEV:3088] RE: CSound API with 4.23f07?
Did you take a look at the csound.dev file in SourceForge CVS for csound?
This is a Dev-C++ project file for a mingw build of the Csound API as a
static library. The canonical makefile is not oriented in this direction at
all. You would need to download Dev-C++ to use this project file, from
which Dev-C++ would generate the actual makefile.

I plan to focus my own efforts on making the API more usable in csound5,
but for mingw, the csound.dev stuff should work for you.

I think it would fairly easy to adapt the makefile generated by Dev-C++ for
mingw to work on Linux, also.

Original Message:
-----------------
From:  ramsdell@mitre.org (John D. Ramsdell)
Date: 15 Sep 2003 10:48:57 -0400
To: csound-dev@eartha.mills.edu, ramsdell@mitre.org
Subject: [CSOUND-DEV:3087] CSound API with 4.23f07?


I have version 4.23f07 of the CSound source distribution, downloaded
from SourceForge after September ninth, and I have no problems
building it in my usual way.  I changed wxCSound so it can be compiled
in a mode that interacts with CSound only through the CSound API, as
long as CSound supports the yield callback.  wxCSound uses the yield
callback to implement user initiated aborts of a CSound run.

I have not been able to build a library implementing the CSound API.
Are there instructions on how to do this?  I've replaced jpff_glue.c
with csound.c in my file build list, and I've edited cs.h so that
POLL_EVENTS is defined to be csoundYield.  The resulting system has
serious linking problems.

For one thing, I'm compiling with RTAUDIO undefined to make the
distribution easy to port, but csound.c expects definitions of various
audio functions.  Even if you hack around this problem, functions such
as csoundOpenLibrary are not defined.  I added load_opcodes.c to the
build list, and found conflicts with dl_opcodes.c.  I removed
dl_opcodes from the build list, and then found csoundLoadExternal was
undefined.  This iterative process did not seem to be converging, so I
stopped.  Should I consider these problems subjects for bug reports,
or is there some trick that would fix my problems?

I also loaded MSYS and MinGW on a Windows 2000 laptop.  I compiled and
installed wxWindows using their configure script with just one
problem.  The wx-config script had to be altered to add
-I/usr/local/include to the C and C++ flags it generates.  I
configured wxCSound, and compiled the code I wrote with no problems.
The CSound code generated a few compile time errors.  Once again,
Should I consider these problems subjects for bug reports, or is there
some trick that would fix my problems?  One error I recall is the file
sfont.c:117 redeclares _errno.

Finally, when I compile CSound with GCC and -Wall, I received a number
of warnings, a few of them look scary.  Should I consider the warnings
a subject of a bug report, or is this situation well known?

John

wxCSound source site: http://www.ccs.neu.edu/home/ramsdell/tools/


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

Date2003-09-16 13:17
Fromramsdell@mitre.org (John D. Ramsdell)
Subject[CSOUND-DEV:3092] RE: CSound API with 4.23f07?
Michael,

Your advice appears to have solved my problem.  I carefully read the
makefile generated by Dev-C++ from csound.dev, and concluded the magic
trick is to use the -DSSOUND switch.

My current local copy of wxCSound links the GUI with CSound only
through the CSound API.  It compiles on both Linux using the usual set
of tools, and on Windows using MSYS and MinGW.  I immediately noticed
that the Windows version has a problem with displaying graphs, and who
knows what else might be wrong.  In any event, the Windows port is
once again progressing thanks to your help.

To make wxCSound work with the API, when building libcsound.a, I
specify

DEFS = -DSYS5 -DSSOUND -DWINDOWS -DHAVE_WX_WINDOWS -DSFIRCAM

after patching the sources as follows.

diff -urN csound-4.23f07/cs.h csound/cs.h
--- csound-4.23f07/cs.h	2003-09-02 12:50:42.000000000 -0400
+++ csound/cs.h	2003-09-16 06:42:16.000000000 -0400
@@ -817,7 +817,10 @@
 
 #include "text.h"
 
-#if defined CWIN
+#if defined HAVE_WX_WINDOWS
+  int csoundYield(void *csound);
+# define POLL_EVENTS() csoundYield(0)
+#elif defined CWIN
 #elif defined(mac_classic) || defined(SYMANTEC)
 # define POLL_EVENTS() STasks()
 # define __cdecl
@@ -839,6 +842,10 @@
 #define printf csoundMessage0
 extern void csoundMessage0(const char *, ...);
 extern void err_printf(char *, ...);
+#elif defined HAVE_WX_WINDOWS
+#define printf wxcsound_printf
+extern void wxcsound_printf(const char *, ...);
+extern void err_printf(char *, ...);
 #else
 #ifdef CWIN
 #include 
diff -urN csound-4.23f07/csound.c csound/csound.c
--- csound-4.23f07/csound.c	2003-09-02 12:50:42.000000000 -0400
+++ csound/csound.c	2003-09-16 06:42:16.000000000 -0400
@@ -611,6 +611,29 @@
     rtclose = rtclose__;
   }
 
+#if !defined RTAUDIO
+  void playopen_(int nchanls, int dsize, float sr, int scale)
+  {
+  }
+
+  void rtplay_(char *outBuf, int nbytes)
+  {
+  }
+
+  void recopen_(int nchanls, int dsize, float sr, int scale)
+  {
+  }
+
+  int rtrecord_(char *inBuf, int nbytes)
+  {
+    return 0;
+  }
+
+  void rtclose_(void)
+  {
+  }
+#endif
+
   /*
    * MIDI -- this code replaces the MIDIDevice.c file
    */
diff -urN csound-4.23f07/load_opcodes.c csound/load_opcodes.c
--- csound-4.23f07/load_opcodes.c	2003-09-02 12:50:43.000000000 -0400
+++ csound/load_opcodes.c	2003-09-16 06:42:16.000000000 -0400
@@ -156,5 +156,20 @@
 {
 	return 0;
 }
+
+#elif defined HAVE_WX_WINDOWS
+
+void *csoundOpenLibrary(const char *libraryPath)
+{
+	return 0;
+}
+void *csoundCloseLibrary(void *library)
+{
+   	return 0;
+}
+void *csoundGetLibrarySymbol(void *library, const char *procedureName)
+{
+	return 0;
+}
 #endif
 
diff -urN csound-4.23f07/main.c csound/main.c
--- csound-4.23f07/main.c	2003-09-02 12:50:43.000000000 -0400
+++ csound/main.c	2003-09-16 06:42:16.000000000 -0400
@@ -245,7 +245,7 @@
     }
 }
 
-void psignal(int sig, char *str)
+void psignal(int sig, const char *str)
 {
     err_printf( "%s: %s\n", str, signal_to_string(sig));
 }
diff -urN csound-4.23f07/mididevice.c csound/mididevice.c
--- csound-4.23f07/mididevice.c	2003-09-02 12:50:44.000000000 -0400
+++ csound/mididevice.c	2003-09-16 06:42:16.000000000 -0400
@@ -109,7 +109,7 @@
      static port_id gMidiInPort = B_ERROR;
 #elif defined(mac_classic)
 
-#elif !defined(DOSGCC) && !defined(__WATCOMC__)&& !defined(LATTICE) && !defined(WIN32) && !defined(SYMANTEC) && !defined(__EMX__)
+#elif !defined(DOSGCC) && !defined(__WATCOMC__)&& !defined(LATTICE) && !defined(WIN32) && !defined(SYMANTEC) && !defined(__EMX__) && !defined(HAVE_WX_WINDOWS)
 #    if defined(__MACH__)
 #      define USE_OLD_TTY 1
 #    endif
@@ -386,7 +386,7 @@
           }
       }
 # endif /* HAVE_BSD_SGTTY_H */
-#elif !defined(__BEOS__) && !defined(mac_classic)
+#elif !defined(__BEOS__) && !defined(mac_classic) && !defined(HAVE_WX_WINDOWS)
 # if !defined(DOSGCC) && !defined(__WATCOMC__) && !defined(LATTICE) && !defined(WIN32) && !defined(__EMX__)
       ioctl(rtfd, TIOCGETP, &tty);           /* for other machines      */
       tty.sg_ispeed = INBAUD;                /*   set baud rate         */

Does this seem reasonable?

John

PS.  By the way, here is a listing of the warnings generated by GCC.
Some of them appear to worth looking at.

sh-2.05b$ grep warning: /tmp/build.log
main.c:324: warning: argument `argc' might be clobbered by `longjmp' or `vfork'
argdecode.c:727: warning: implicit declaration of function `dup'
argdecode.c:729: warning: implicit declaration of function `dup2'
musmon.c:235: warning: implicit declaration of function `csoundIsExternalMidiEnabled'
musmon.c:237: warning: implicit declaration of function `csoundExternalMidiOpen'
otran.c:844: warning: double format, float arg (arg 3)
oload.c:602: warning: `csetoffbas' might be used uninitialized in this function
oload.c:606: warning: `chp' might be used uninitialized in this function
rdscor.c:71: warning: double format, float arg (arg 3)
hetro.c:551: warning: implicit declaration of function `write'
lpanal.c:615: warning: implicit declaration of function `write'
lpanal.c:776: warning: implicit declaration of function `close'
pvanal.c:272: warning: implicit declaration of function `write'
pvanal.c:289: warning: implicit declaration of function `close'
sndinfo.c:140: warning: implicit declaration of function `close'
sfheader.c:417: warning: implicit declaration of function `write'
sfheader.c:508: warning: implicit declaration of function `lseek'
soundin.c:150: warning: implicit declaration of function `read'
soundin.c:399: warning: implicit declaration of function `lseek'
soundin.c:414: warning: implicit declaration of function `close'
soundio.c:371: warning: `audwrt4' defined but not used
aiff.c:228: warning: implicit declaration of function `read'
wave.c:144: warning: implicit declaration of function `write'
wave.c:155: warning: implicit declaration of function `lseek'
wave.c:265: warning: implicit declaration of function `read'
memfiles.c:66: warning: implicit declaration of function `read'
memfiles.c:68: warning: implicit declaration of function `close'
auxfd.c:83: warning: implicit declaration of function `close'
dumpf.c:204: warning: implicit declaration of function `write'
dumpf.c:377: warning: implicit declaration of function `read'
dumpf.c:417: warning: implicit declaration of function `lseek'
dumpf.c:421: warning: double format, float arg (arg 3)
dumpf.c:438: warning: double format, float arg (arg 3)
cvanal.c:99: warning: double format, float arg (arg 3)
cvanal.c:112: warning: double format, float arg (arg 3)
cvanal.c:119: warning: double format, float arg (arg 3)
cvanal.c:158: warning: implicit declaration of function `write'
cvanal.c:167: warning: implicit declaration of function `close'
cvanal.c:279: warning: `PrintBuf' defined but not used
hrtferX.c:166: warning: unused variable `yr2'
hrtferX.c:166: warning: unused variable `yl2'
hrtferX.c:590: warning: unused variable `c1'
diskin.c:73: warning: implicit declaration of function `read'
diskin.c:239: warning: implicit declaration of function `close'
diskin.c:321: warning: implicit declaration of function `lseek'
diskin.c:1697: warning: implicit declaration of function `write'
aifc.c:150: warning: implicit declaration of function `write'
aifc.c:171: warning: implicit declaration of function `lseek'
aifc.c:219: warning: implicit declaration of function `read'
mxfft.c:186: warning: `k3' might be used uninitialized in this function
mxfft.c:193: warning: `c2' might be used uninitialized in this function
mxfft.c:193: warning: `c3' might be used uninitialized in this function
mxfft.c:196: warning: `s2' might be used uninitialized in this function
mxfft.c:196: warning: `s3' might be used uninitialized in this function
mxfft.c:29: warning: `rcsid' defined but not used
pvfileio.c:154: warning: implicit declaration of function `write'
pvfileio.c:285: warning: implicit declaration of function `read'
pvfileio.c:508: warning: implicit declaration of function `close'
pvfileio.c:853: warning: implicit declaration of function `lseek'
dnoise.c:306: warning: implicit declaration of function `dup'
dnoise.c:308: warning: implicit declaration of function `dup2'
dnoise.c:1185: warning: implicit declaration of function `close'
dnoise.c:1238: warning: implicit declaration of function `write'
dnoise.c:1243: warning: implicit declaration of function `lseek'
mididevice.c:486: warning: unused variable `n'
csound.c:140: warning: suggest parentheses around assignment used as truth value
csound.c:155: warning: suggest parentheses around assignment used as truth value
csound.c:171: warning: suggest parentheses around assignment used as truth value
csound.c:214: warning: suggest parentheses around assignment used as truth value
csound.c:211: warning: variable `done' might be clobbered by `longjmp' or `vfork'
csound.c:733: warning: implicit declaration of function `MakeAscii'
csound.c:750: warning: implicit declaration of function `DrawAscii'
csound.c:767: warning: implicit declaration of function `KillAscii'
csound.c:876: warning: suggest parentheses around assignment used as truth value
csound.c:879: warning: suggest parentheses around assignment used as truth value
csound.c:888: warning: suggest parentheses around assignment used as truth value
csound.c:891: warning: suggest parentheses around assignment used as truth value
csound.c:201: warning: `_rtInputBufSize' defined but not used
csound.c:202: warning: `_rtInputBufIndex' defined but not used
dl_opcodes.c:51: warning: unused variable `size'
dl_opcodes.c:50: warning: unused variable `init'
dl_opcodes.c:48: warning: unused variable `error'
dl_opcodes.c:144: warning: label `next' defined but not used
dl_opcodes.c:74: warning: `opcodlst_n' might be used uninitialized in this function
dl_opcodes.c:75: warning: `length' might be used uninitialized in this function
dl_opcodes.c:75: warning: `olength' might be used uninitialized in this function
makedb.c:104: warning: int format, long int arg (arg 3)
makedb.c:109: warning: int format, long int arg (arg 3)
makedb.c:109: warning: int format, long int arg (arg 4)
sh-2.05b$ 

"gogins@pipeline.com"  writes:

> Did you take a look at the csound.dev file in SourceForge CVS for csound?
> This is a Dev-C++ project file for a mingw build of the Csound API as a
> static library. The canonical makefile is not oriented in this direction at
> all. You would need to download Dev-C++ to use this project file, from
> which Dev-C++ would generate the actual makefile.

Date2003-09-24 13:40
Fromramsdell@mitre.org (John D. Ramsdell)
Subject[CSOUND-DEV:3096] CSound API with wxCSound
What is the proper way to invoke CSound via the CSound API?  Following
the instructions in csound.h, I wrote a C++ object with this form:

Synthesizer::Synthesizer()
  : m_csound(csoundCreate(this))
{
  ... set up callbacks
}

int Synthesizer::perform(int argc, char **argv)
{
  Main& app = wxGetApp();
  app.post_clear_plots();
  int rc = csoundCompile(m_csound, argc, argv);
  if (!rc)
    while(!csoundPerformBuffer(m_csound));
  csoundCleanup(m_csound);
  csoundReset(m_csound);
  return rc;
}

Maybe instead, I should be simply calling csoundPerform, then
csoundCleanup, and then csoundReset.  Then again, I notice the
CsoundVST calls csoundPerformKsmps instead of calling
csoundPerformBuffer in a while loop.  So what should I be doing in
wxCSound's perform method?

John