cursynth icon indicating copy to clipboard operation
cursynth copied to clipboard

building on Windows

Open lm8 opened this issue 11 years ago • 1 comments

Tried building cursynth on Windows using MinGW and msys. It builds successfully, but it needed the following patches to do so. While either ncurses of pdcurses is available on both Linux, BSD and Windows platforms, Windows builds typically use pdcurses. I replaced the link to the ncurses library in src/Makefile with -lpdcurses and the patches switch from the ncurses header to the pdcurses header file on Windows. Might be nicer to give the user the option to pick ncurses or pdcurses instead of defaulting by platform. Also, on most systems mkdir takes to arguments, but on Windows, it just takes one. Windows streams are typically text instead of binary based unless specified as binary.

diff -Naurp src/cursynth-1.4/rtaudio/RtAudio.cpp tmp/cursynth-1.4/rtaudio/RtAudio.cpp --- src/cursynth-1.4/rtaudio/RtAudio.cpp 2014-01-21 21:31:39 -0500 +++ tmp/cursynth-1.4/rtaudio/RtAudio.cpp
@@ -3558,6 +3558,7 @@ static const char* getAsioErrorString( A #pragma comment( lib, "winmm.lib" ) // then, auto-link winmm.lib. Otherwise, it has to be added manually. #endif

+#include <stdio.h> static inline DWORD dsPointerBetween( DWORD pointer, DWORD laterPointer, DWORD earlierPointer, DWORD bufferSize ) { if ( pointer > bufferSize ) pointer -= bufferSize; @@ -7130,6 +7131,9 @@ bool RtApiOss :: probeDeviceOpen( unsign

// Try to open the device. int fd; +#ifdef _WIN32

  • flags |-= O_BINARY; +#endif fd = open( ainfo.devnode, flags, 0 ); if ( fd == -1 ) { if ( errno == EBUSY ) diff -Naurp src/cursynth-1.4/src/cursynth.cpp tmp/cursynth-1.4/src/cursynth.cpp --- src/cursynth-1.4/src/cursynth.cpp 2014-02-04 20:43:48 -0500 +++ tmp/cursynth-1.4/src/cursynth.cpp
    @@ -22,7 +22,11 @@

include <dirent.h>

include

include

+#ifdef _WIN32 +#include <curses.h> +#else

include <ncurses.h>

+#endif

include

include

include <stdio.h>

@@ -56,8 +60,10 @@ namespace { RtAudioStreamStatus status, void *user_data) { UNUSED(in_buffer); UNUSED(stream_time); +#ifndef _WIN32
if (status) std::cout << "Stream underflow detected!" << std::endl; +#endif

mopo::Cursynth* cursynth = static_castmopo::Cursynth*(user_data); cursynth->processAudio((mopo::mopo_float*)out_buffer, n_frames); @@ -88,7 +94,11 @@ namespace { // Check if the directory path exists, if not, create it. void confirmPathExists(std::string path) { if (opendir(path.c_str()) == NULL) +#ifdef _WIN32

  •  mkdir(path.c_str());
    

    +#else
    mkdir(path.c_str(), 0755); +#endif
    }

    // Returns all files in directory dir with extenstion ext. diff -Naurp src/cursynth-1.4/src/cursynth_gui.cpp tmp/cursynth-1.4/src/cursynth_gui.cpp --- src/cursynth-1.4/src/cursynth_gui.cpp 2014-03-15 18:26:00 -0400 +++ tmp/cursynth-1.4/src/cursynth_gui.cpp
    @@ -21,7 +21,11 @@

    include <libintl.h>

    include <locale.h>

    include <math.h>

    +#ifdef _WIN32 +#include <curses.h> +#else

    include <ncurses.h>

    +#endif

    include <stdlib.h>

    include

    include <unistd.h>

    diff -Naurp src/cursynth-1.4/src/cursynth_gui.h tmp/cursynth-1.4/src/cursynth_gui.h --- src/cursynth-1.4/src/cursynth_gui.h 2014-02-04 20:43:48 -0500 +++ tmp/cursynth-1.4/src/cursynth_gui.h @@ -22,7 +22,11 @@

    include "cursynth_common.h"

    include

    +#ifdef _WIN32 +#include <curses.h> +#else

    include <ncurses.h>

    +#endif

    include

    namespace mopo {

lm8 avatar Apr 01 '14 11:04 lm8

Hey! Sorry I didn't respond for a while. I'll look this over and get back to you.

iyoko avatar Apr 14 '14 02:04 iyoko