Added examples and packages for audio playback.
authorDaniel Giritzer <giri@nwrk.biz>
Sat, 29 Dec 2018 01:42:47 +0000 (02:42 +0100)
committerDaniel Giritzer <giri@nwrk.biz>
Sat, 29 Dec 2018 01:42:47 +0000 (02:42 +0100)
examples/audio1/Makefile [new file with mode: 0644]
examples/audio1/ao_example.cxx [new file with mode: 0644]
examples/audio2/Makefile [new file with mode: 0644]
examples/audio2/ao_example.cxx [new file with mode: 0644]
examples/audio2/test.wav [new file with mode: 0644]
packages/fltk/Makefile
packages/libao/.gitignore [new file with mode: 0644]
packages/libao/Makefile
packages/libsndfile/.gitignore [new file with mode: 0644]
packages/libsndfile/Makefile [new file with mode: 0644]
packages/libsndfile/libsndfile-1.0.28.tar.gz [new file with mode: 0644]

diff --git a/examples/audio1/Makefile b/examples/audio1/Makefile
new file mode 100644 (file)
index 0000000..545aba4
--- /dev/null
@@ -0,0 +1,209 @@
+############################################################################
+# Workfile: Makefile
+# Author: Daniel Giritzer, S1810567004 (daniel@giritzer.eu)
+# Date: 03.12.2018
+# Description: Universal Makefile for Unix based Operating Systems
+############################################################################
+
+###################################
+#GENERAL | EDIT 1/7
+###################################
+WORKDIR = $(shell pwd)
+SOURCES := $(shell ls *.cxx)
+PROJNAME = audio_test
+LIBDIR =
+INC = -I$(WORKDIR)/../../include -I$(WORKDIR)/../../../include
+LDFLAGS = -m32 -static-libstdc++ -static-libgcc -Wl,-Bstatic
+CFLAGS = -m32 -Wall -fexceptions -std=c++11 -static-libstdc++ -static-libgcc
+LIB =
+
+###################################
+#GCC | EDIT 2/7
+###################################
+CC_GCC = gcc
+CXX_GCC = g++
+AR_GCC = ar
+LD_GCC = g++
+WINDRES_GCC = windres
+
+INC_GCC = $(INC)
+LIBDIR_GCC = -L$(WORKDIR)/../../lib/linux32 -L$(WORKDIR)/../../../lib/linux32
+CFLAGS_GCC = $(CFLAGS)
+RESINC_GCC =
+LDFLAGS_GCC = $(LDFLAGS)
+LIB_GCC = $(LIB) -lpthread -ldl -lm -Wl,-Bdynamic -lao
+
+
+###################################
+#MinGW | EDIT 3/7
+###################################
+CC_WIN = i686-w64-mingw32-gcc
+CXX_WIN = i686-w64-mingw32-g++
+AR_WIN = i686-w64-mingw32-ar
+LD_WIN = i686-w64-mingw32-g++
+WINDRES_WIN = i686-w64-mingw32-windres
+
+INC_WIN = $(INC)
+LIBDIR_WIN = -L$(WORKDIR)/../../lib/mingw32 -L$(WORKDIR)/../../../lib/mingw32
+CFLAGS_WIN = $(CFLAGS) -mconsole -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+RESINC_WIN =
+LDFLAGS_WIN =  $(LDFLAGS)
+LIB_WIN = $(LIB) -static -lao -mconsole -lole32 -luuid -lcomctl32 -lpthread -lksuser -lwinmm
+
+###################################
+#RELEASE GCC SETTINGS | EDIT: 4/7
+###################################
+INC_RELEASE_GCC = $(INC_GCC)
+CFLAGS_RELEASE_GCC = $(CFLAGS_GCC) -O2
+RESINC_RELEASE_GCC = $(RESINC_GCC)
+RCFLAGS_RELEASE_GCC = $(RCFLAGS_GCC)
+LIBDIR_RELEASE_GCC = $(LIBDIR_GCC)
+LIB_RELEASE_GCC = $(LIB_GCC)
+LDFLAGS_RELEASE_GCC = $(LDFLAGS_GCC) -s
+OBJDIR_RELEASE_GCC = obj/Release_Linux
+DEP_RELEASE_GCC =
+OUT_RELEASE_GCC = bin/Release_Linux
+
+###################################
+#DEBUG GCC SETTINGS | EDIT: 5/7
+###################################
+INC_DEBUG_GCC = $(INC_GCC)
+CFLAGS_DEBUG_GCC = $(CFLAGS_GCC) -g
+RESINC_DEBUG_GCC = $(RESINC_GCC)
+RCFLAGS_DEBUG_GCC = $(RCFLAGS_GCC)
+LIBDIR_DEBUG_GCC = $(LIBDIR_GCC)
+LIB_DEBUG_GCC = $(LIB_GCC)
+LDFLAGS_DEBUG_GCC = $(LDFLAGS_GCC)
+OBJDIR_DEBUG_GCC = obj/Debug_Linux
+DEP_DEBUG_GCC =
+OUT_DEBUG_GCC = bin/Debug_Linux
+
+###################################
+#RELEASE MinGW SETTINGS | EDIT: 6/7
+###################################
+INC_RELEASE_WIN = $(INC_WIN)
+CFLAGS_RELEASE_WIN = $(CFLAGS_WIN) -O2
+RESINC_RELEASE_WIN = $(RESINC_WIN)
+RCFLAGS_RELEASE_WIN = $(RCFLAGS_WIN)
+LIBDIR_RELEASE_WIN = $(LIBDIR_WIN)
+LIB_RELEASE_WIN = $(LIB_WIN)
+LDFLAGS_RELEASE_WIN = $(LDFLAGS_WIN) -s
+OBJDIR_RELEASE_WIN = obj/Release_Windows
+DEP_RELEASE_WIN =
+OUT_RELEASE_WIN = bin/Release_Windows
+
+###################################
+#DEBUG MinGW SETTINGS | EDIT: 7/7
+###################################
+INC_DEBUG_WIN = $(INC_WIN)
+CFLAGS_DEBUG_WIN = $(CFLAGS_WIN) -g
+RESINC_DEBUG_WIN = $(RESINC_WIN)
+RCFLAGS_DEBUG_WIN = $(RCFLAGS_WIN)
+LIBDIR_DEBUG_WIN = $(LIBDIR_WIN)
+LIB_DEBUG_WIN = $(LIB_WIN)
+LDFLAGS_DEBUG_WIN = $(LDFLAGS_WIN)
+OBJDIR_DEBUG_WIN = obj/Debug_Windows
+DEP_DEBUG_WIN =
+OUT_DEBUG_WIN = bin/Debug_Windows
+
+############################
+#OBJECT LISTS | DO NOT EDIT!
+############################
+OBJ_DEBUG_GCC = $(addprefix $(OBJDIR_DEBUG_GCC)/,$(SOURCES:%.cxx=%.o))
+OBJ_RELEASE_GCC = $(addprefix $(OBJDIR_RELEASE_GCC)/,$(SOURCES:%.cxx=%.o))
+OBJ_DEBUG_WIN = $(addprefix $(OBJDIR_DEBUG_WIN)/,$(SOURCES:%.cxx=%.o))
+OBJ_RELEASE_WIN = $(addprefix $(OBJDIR_RELEASE_WIN)/,$(SOURCES:%.cxx=%.o))
+
+##########################
+#FUNCTIONS | DO NOT EDIT!
+##########################
+
+######## General
+all: debug release
+clean: clean_debug_linux clean_release_linux clean_debug_windows clean_release_windows
+rebuild: clean debug release
+
+debug Debug: debug_linux debug_windows
+release Release:  release_linux release_windows
+
+######## DEBUG GCC
+before_debug_linux:
+       test -d $(OUT_DEBUG_GCC) || mkdir -p $(OUT_DEBUG_GCC)
+       test -d $(OBJDIR_DEBUG_GCC) || mkdir -p $(OBJDIR_DEBUG_GCC)
+
+after_debug_linux:
+
+debug_linux: before_debug_linux out_debug_linux after_debug_linux
+
+out_debug_linux: before_debug_linux $(OBJ_DEBUG_GCC) $(DEP_DEBUG_GCC)
+       $(LD_GCC) $(LDFLAGS_DEBUG_GCC) $(LIBDIR_GCC) $(LIBDIR_DEBUG_GCC) $(OBJ_DEBUG_GCC) $(LIB_DEBUG_GCC)  -o $(OUT_DEBUG_GCC)/$(PROJNAME)
+
+$(OBJDIR_DEBUG_GCC)/%.o: %.cxx
+       $(CXX_GCC) $(CFLAGS_DEBUG_GCC) $(INC_DEBUG_GCC) -c $< -D_DEBUG -o $@
+
+clean_debug_linux:
+       rm -f $(OBJ_DEBUG_GCC) $(OUT_DEBUG_GCC)/$(PROJNAME)
+       rm -rf $(OUT_DEBUG_GCC)
+       rm -rf $(OBJDIR_DEBUG_GCC)
+
+######## RELEASE GCC
+before_release_linux:
+       test -d $(OUT_RELEASE_GCC) || mkdir -p $(OUT_RELEASE_GCC)
+       test -d $(OBJDIR_RELEASE_GCC) || mkdir -p $(OBJDIR_RELEASE_GCC)
+
+after_release_linux:
+
+release_linux: before_release_linux out_release_linux after_release_linux
+
+out_release_linux: before_release_linux $(OBJ_RELEASE_GCC) $(DEP_RELEASE_GCC)
+       $(LD_GCC) $(LDFLAGS_RELEASE_GCC) $(LIBDIR_GCC) $(LIBDIR_RELEASE_GCC) $(OBJ_RELEASE_GCC) $(LIB_RELEASE_GCC)  -o $(OUT_RELEASE_GCC)/$(PROJNAME)
+
+$(OBJDIR_RELEASE_GCC)/%.o: %.cxx
+       $(CXX_GCC) $(CFLAGS_RELEASE_GCC) $(INC_RELEASE_GCC) -c $< -D_RELEASE -o $@
+
+clean_release_linux:
+       rm -f $(OBJ_RELEASE_GCC) $(OUT_RELEASE_GCC)/$(PROJNAME)
+       rm -rf $(OUT_RELEASE_GCC)
+       rm -rf $(OBJDIR_RELEASE_GCC)
+
+######## DEBUG WIN
+before_debug_windows:
+       test -d $(OUT_DEBUG_WIN) || mkdir -p $(OUT_DEBUG_WIN)
+       test -d $(OBJDIR_DEBUG_WIN) || mkdir -p $(OBJDIR_DEBUG_WIN)
+
+after_debug_windows:
+
+debug_windows: before_debug_windows out_debug_windows after_debug_windows
+
+out_debug_windows: before_debug_windows $(OBJ_DEBUG_WIN) $(DEP_DEBUG_WIN)
+       $(LD_WIN) $(LDFLAGS_DEBUG_WIN) $(LIBDIR_WIN) $(LIBDIR_DEBUG_WIN) $(OBJ_DEBUG_WIN) $(LIB_DEBUG_WIN)  -o $(OUT_DEBUG_WIN)/$(PROJNAME).exe
+
+$(OBJDIR_DEBUG_WIN)/%.o: %.cxx
+       $(CXX_WIN) $(CFLAGS_DEBUG_WIN) $(INC_DEBUG_WIN) -c $< -D_DEBUG -o $@
+
+clean_debug_windows:
+       rm -f $(OBJ_DEBUG_WIN) $(OUT_DEBUG_WIN)/$(PROJNAME).exe
+       rm -rf $(OUT_DEBUG_WIN)
+       rm -rf $(OBJDIR_DEBUG_WIN)
+
+######## RELEASE WIN
+before_release_windows:
+       test -d $(OUT_RELEASE_WIN) || mkdir -p $(OUT_RELEASE_WIN)
+       test -d $(OBJDIR_RELEASE_WIN) || mkdir -p $(OBJDIR_RELEASE_WIN)
+
+after_release_windows:
+
+release_windows: before_release_windows out_release_windows after_release_windows
+
+out_release_windows: before_release_windows $(OBJ_RELEASE_WIN) $(DEP_RELEASE_WIN)
+       $(LD_WIN) $(LDFLAGS_RELEASE_WIN) $(LIBDIR_WIN) $(LIBDIR_RELEASE_WIN) $(OBJ_RELEASE_WIN) $(LIB_RELEASE_WIN)  -o $(OUT_RELEASE_WIN)/$(PROJNAME).exe
+
+$(OBJDIR_RELEASE_WIN)/%.o: %.cxx
+       $(CXX_WIN) $(CFLAGS_RELEASE_WIN) $(INC_RELEASE_WIN) -c $< -D_RELEASE -o $@
+
+clean_release_windows:
+       rm -f $(OBJ_RELEASE_WIN) $(OUT_RELEASE_WIN)/$(PROJNAME).exe
+       rm -rf $(OUT_RELEASE_WIN)
+       rm -rf $(OBJDIR_RELEASE_WIN)
+
+.PHONY: before_debug_linux out_debug_linux after_debug_linux before_release_linux out_release_linux after_release_linux before_debug_windows out_debug_windows after_debug_windows before_release_windows out_release_windows after_release_windows
diff --git a/examples/audio1/ao_example.cxx b/examples/audio1/ao_example.cxx
new file mode 100644 (file)
index 0000000..c70cee8
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ *
+ * ao_example.c
+ *
+ *     Written by Stan Seibert - July 2001
+ *
+ * Legal Terms:
+ *
+ *     This source file is released into the public domain.  It is
+ *     distributed without any warranty; without even the implied
+ *     warranty * of merchantability or fitness for a particular
+ *     purpose.
+ *
+ * Function:
+ *
+ *     This program opens the default driver and plays a 440 Hz tone for
+ *     one second.
+ *
+ * Compilation command line (for Linux systems):
+ *
+ *     gcc -o ao_example ao_example.c -lao -ldl -lm
+ *
+ */
+#define _USE_MATH_DEFINES
+#include <iostream>
+#include <stdio.h>
+#include <string.h>
+#include <ao/ao.h>
+#include <math.h>
+
+#define BUF_SIZE 4096
+
+int main(int argc, char **argv)
+{
+       ao_device *device;
+       ao_sample_format format;
+       int default_driver;
+       char *buffer;
+       int buf_size;
+       int sample;
+       float freq = 440.0;
+       int i;
+
+       /* -- Initialize -- */
+
+       fprintf(stderr, "libao example program\n");
+
+       ao_initialize();
+
+       /* -- Setup for default driver -- */
+
+       default_driver = ao_default_driver_id();
+
+       std::cout << "default: " << ao_default_driver_id() << " pulse: " << ao_driver_id("pulse") << " alsa: " << ao_driver_id("alsa") << " wmm: " << ao_driver_id("alsa")  << std::endl;
+
+       
+
+        memset(&format, 0, sizeof(format));
+       format.bits = 16;
+       format.channels = 2;
+       format.rate = 44100;
+       format.byte_format = AO_FMT_LITTLE;
+
+       /* -- Open driver -- */
+       device = ao_open_live(default_driver, &format, NULL /* no options */);
+       if (device == NULL) {
+               fprintf(stderr, "Error opening device.\n");
+               //return 1;
+       }
+
+       /* -- Play some stuff -- */
+       buf_size = format.bits/8 * format.channels * format.rate;
+       buffer = (char*)calloc(buf_size,
+                       sizeof(char));
+
+       for (i = 0; i < format.rate; i++) {
+               sample = (int)(0.75 * 32768.0 *
+                       sin(2 * M_PI * freq * ((float) i/format.rate)));
+
+               /* Put the same stuff in left and right channel */
+               buffer[4*i] = buffer[4*i+2] = sample & 0xff;
+               buffer[4*i+1] = buffer[4*i+3] = (sample >> 8) & 0xff;
+       }
+       ao_play(device, buffer, buf_size);
+
+       /* -- Close and shutdown -- */
+       ao_close(device);
+
+       ao_shutdown();
+
+  return (0);
+}
diff --git a/examples/audio2/Makefile b/examples/audio2/Makefile
new file mode 100644 (file)
index 0000000..b2d9998
--- /dev/null
@@ -0,0 +1,209 @@
+############################################################################
+# Workfile: Makefile
+# Author: Daniel Giritzer, S1810567004 (daniel@giritzer.eu)
+# Date: 03.12.2018
+# Description: Universal Makefile for Unix based Operating Systems
+############################################################################
+
+###################################
+#GENERAL | EDIT 1/7
+###################################
+WORKDIR = $(shell pwd)
+SOURCES := $(shell ls *.cxx)
+PROJNAME = audio_test
+LIBDIR =
+INC = -I$(WORKDIR)/../../include -I$(WORKDIR)/../../../include
+LDFLAGS = -m32 -static-libstdc++ -static-libgcc -Wl,-Bstatic
+CFLAGS = -m32 -Wall -fexceptions -std=c++11 -static-libstdc++ -static-libgcc
+LIB = -lsndfile
+
+###################################
+#GCC | EDIT 2/7
+###################################
+CC_GCC = gcc
+CXX_GCC = g++
+AR_GCC = ar
+LD_GCC = g++
+WINDRES_GCC = windres
+
+INC_GCC = $(INC)
+LIBDIR_GCC = -L$(WORKDIR)/../../lib/linux32 -L$(WORKDIR)/../../../lib/linux32
+CFLAGS_GCC = $(CFLAGS)
+RESINC_GCC =
+LDFLAGS_GCC = $(LDFLAGS)
+LIB_GCC = $(LIB) -lpthread -ldl -lm -Wl,-Bdynamic -lao
+
+
+###################################
+#MinGW | EDIT 3/7
+###################################
+CC_WIN = i686-w64-mingw32-gcc
+CXX_WIN = i686-w64-mingw32-g++
+AR_WIN = i686-w64-mingw32-ar
+LD_WIN = i686-w64-mingw32-g++
+WINDRES_WIN = i686-w64-mingw32-windres
+
+INC_WIN = $(INC)
+LIBDIR_WIN = -L$(WORKDIR)/../../lib/mingw32 -L$(WORKDIR)/../../../lib/mingw32
+CFLAGS_WIN = $(CFLAGS) -mconsole -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+RESINC_WIN =
+LDFLAGS_WIN =  $(LDFLAGS)
+LIB_WIN = $(LIB) -static -lao -mconsole -lole32 -luuid -lcomctl32 -lpthread -lksuser -lwinmm
+
+###################################
+#RELEASE GCC SETTINGS | EDIT: 4/7
+###################################
+INC_RELEASE_GCC = $(INC_GCC)
+CFLAGS_RELEASE_GCC = $(CFLAGS_GCC) -O2
+RESINC_RELEASE_GCC = $(RESINC_GCC)
+RCFLAGS_RELEASE_GCC = $(RCFLAGS_GCC)
+LIBDIR_RELEASE_GCC = $(LIBDIR_GCC)
+LIB_RELEASE_GCC = $(LIB_GCC)
+LDFLAGS_RELEASE_GCC = $(LDFLAGS_GCC) -s
+OBJDIR_RELEASE_GCC = obj/Release_Linux
+DEP_RELEASE_GCC =
+OUT_RELEASE_GCC = bin/Release_Linux
+
+###################################
+#DEBUG GCC SETTINGS | EDIT: 5/7
+###################################
+INC_DEBUG_GCC = $(INC_GCC)
+CFLAGS_DEBUG_GCC = $(CFLAGS_GCC) -g
+RESINC_DEBUG_GCC = $(RESINC_GCC)
+RCFLAGS_DEBUG_GCC = $(RCFLAGS_GCC)
+LIBDIR_DEBUG_GCC = $(LIBDIR_GCC)
+LIB_DEBUG_GCC = $(LIB_GCC)
+LDFLAGS_DEBUG_GCC = $(LDFLAGS_GCC)
+OBJDIR_DEBUG_GCC = obj/Debug_Linux
+DEP_DEBUG_GCC =
+OUT_DEBUG_GCC = bin/Debug_Linux
+
+###################################
+#RELEASE MinGW SETTINGS | EDIT: 6/7
+###################################
+INC_RELEASE_WIN = $(INC_WIN)
+CFLAGS_RELEASE_WIN = $(CFLAGS_WIN) -O2
+RESINC_RELEASE_WIN = $(RESINC_WIN)
+RCFLAGS_RELEASE_WIN = $(RCFLAGS_WIN)
+LIBDIR_RELEASE_WIN = $(LIBDIR_WIN)
+LIB_RELEASE_WIN = $(LIB_WIN)
+LDFLAGS_RELEASE_WIN = $(LDFLAGS_WIN) -s
+OBJDIR_RELEASE_WIN = obj/Release_Windows
+DEP_RELEASE_WIN =
+OUT_RELEASE_WIN = bin/Release_Windows
+
+###################################
+#DEBUG MinGW SETTINGS | EDIT: 7/7
+###################################
+INC_DEBUG_WIN = $(INC_WIN)
+CFLAGS_DEBUG_WIN = $(CFLAGS_WIN) -g
+RESINC_DEBUG_WIN = $(RESINC_WIN)
+RCFLAGS_DEBUG_WIN = $(RCFLAGS_WIN)
+LIBDIR_DEBUG_WIN = $(LIBDIR_WIN)
+LIB_DEBUG_WIN = $(LIB_WIN)
+LDFLAGS_DEBUG_WIN = $(LDFLAGS_WIN)
+OBJDIR_DEBUG_WIN = obj/Debug_Windows
+DEP_DEBUG_WIN =
+OUT_DEBUG_WIN = bin/Debug_Windows
+
+############################
+#OBJECT LISTS | DO NOT EDIT!
+############################
+OBJ_DEBUG_GCC = $(addprefix $(OBJDIR_DEBUG_GCC)/,$(SOURCES:%.cxx=%.o))
+OBJ_RELEASE_GCC = $(addprefix $(OBJDIR_RELEASE_GCC)/,$(SOURCES:%.cxx=%.o))
+OBJ_DEBUG_WIN = $(addprefix $(OBJDIR_DEBUG_WIN)/,$(SOURCES:%.cxx=%.o))
+OBJ_RELEASE_WIN = $(addprefix $(OBJDIR_RELEASE_WIN)/,$(SOURCES:%.cxx=%.o))
+
+##########################
+#FUNCTIONS | DO NOT EDIT!
+##########################
+
+######## General
+all: debug release
+clean: clean_debug_linux clean_release_linux clean_debug_windows clean_release_windows
+rebuild: clean debug release
+
+debug Debug: debug_linux debug_windows
+release Release:  release_linux release_windows
+
+######## DEBUG GCC
+before_debug_linux:
+       test -d $(OUT_DEBUG_GCC) || mkdir -p $(OUT_DEBUG_GCC)
+       test -d $(OBJDIR_DEBUG_GCC) || mkdir -p $(OBJDIR_DEBUG_GCC)
+
+after_debug_linux:
+
+debug_linux: before_debug_linux out_debug_linux after_debug_linux
+
+out_debug_linux: before_debug_linux $(OBJ_DEBUG_GCC) $(DEP_DEBUG_GCC)
+       $(LD_GCC) $(LDFLAGS_DEBUG_GCC) $(LIBDIR_GCC) $(LIBDIR_DEBUG_GCC) $(OBJ_DEBUG_GCC) $(LIB_DEBUG_GCC)  -o $(OUT_DEBUG_GCC)/$(PROJNAME)
+
+$(OBJDIR_DEBUG_GCC)/%.o: %.cxx
+       $(CXX_GCC) $(CFLAGS_DEBUG_GCC) $(INC_DEBUG_GCC) -c $< -D_DEBUG -o $@
+
+clean_debug_linux:
+       rm -f $(OBJ_DEBUG_GCC) $(OUT_DEBUG_GCC)/$(PROJNAME)
+       rm -rf $(OUT_DEBUG_GCC)
+       rm -rf $(OBJDIR_DEBUG_GCC)
+
+######## RELEASE GCC
+before_release_linux:
+       test -d $(OUT_RELEASE_GCC) || mkdir -p $(OUT_RELEASE_GCC)
+       test -d $(OBJDIR_RELEASE_GCC) || mkdir -p $(OBJDIR_RELEASE_GCC)
+
+after_release_linux:
+
+release_linux: before_release_linux out_release_linux after_release_linux
+
+out_release_linux: before_release_linux $(OBJ_RELEASE_GCC) $(DEP_RELEASE_GCC)
+       $(LD_GCC) $(LDFLAGS_RELEASE_GCC) $(LIBDIR_GCC) $(LIBDIR_RELEASE_GCC) $(OBJ_RELEASE_GCC) $(LIB_RELEASE_GCC)  -o $(OUT_RELEASE_GCC)/$(PROJNAME)
+
+$(OBJDIR_RELEASE_GCC)/%.o: %.cxx
+       $(CXX_GCC) $(CFLAGS_RELEASE_GCC) $(INC_RELEASE_GCC) -c $< -D_RELEASE -o $@
+
+clean_release_linux:
+       rm -f $(OBJ_RELEASE_GCC) $(OUT_RELEASE_GCC)/$(PROJNAME)
+       rm -rf $(OUT_RELEASE_GCC)
+       rm -rf $(OBJDIR_RELEASE_GCC)
+
+######## DEBUG WIN
+before_debug_windows:
+       test -d $(OUT_DEBUG_WIN) || mkdir -p $(OUT_DEBUG_WIN)
+       test -d $(OBJDIR_DEBUG_WIN) || mkdir -p $(OBJDIR_DEBUG_WIN)
+
+after_debug_windows:
+
+debug_windows: before_debug_windows out_debug_windows after_debug_windows
+
+out_debug_windows: before_debug_windows $(OBJ_DEBUG_WIN) $(DEP_DEBUG_WIN)
+       $(LD_WIN) $(LDFLAGS_DEBUG_WIN) $(LIBDIR_WIN) $(LIBDIR_DEBUG_WIN) $(OBJ_DEBUG_WIN) $(LIB_DEBUG_WIN)  -o $(OUT_DEBUG_WIN)/$(PROJNAME).exe
+
+$(OBJDIR_DEBUG_WIN)/%.o: %.cxx
+       $(CXX_WIN) $(CFLAGS_DEBUG_WIN) $(INC_DEBUG_WIN) -c $< -D_DEBUG -o $@
+
+clean_debug_windows:
+       rm -f $(OBJ_DEBUG_WIN) $(OUT_DEBUG_WIN)/$(PROJNAME).exe
+       rm -rf $(OUT_DEBUG_WIN)
+       rm -rf $(OBJDIR_DEBUG_WIN)
+
+######## RELEASE WIN
+before_release_windows:
+       test -d $(OUT_RELEASE_WIN) || mkdir -p $(OUT_RELEASE_WIN)
+       test -d $(OBJDIR_RELEASE_WIN) || mkdir -p $(OBJDIR_RELEASE_WIN)
+
+after_release_windows:
+
+release_windows: before_release_windows out_release_windows after_release_windows
+
+out_release_windows: before_release_windows $(OBJ_RELEASE_WIN) $(DEP_RELEASE_WIN)
+       $(LD_WIN) $(LDFLAGS_RELEASE_WIN) $(LIBDIR_WIN) $(LIBDIR_RELEASE_WIN) $(OBJ_RELEASE_WIN) $(LIB_RELEASE_WIN)  -o $(OUT_RELEASE_WIN)/$(PROJNAME).exe
+
+$(OBJDIR_RELEASE_WIN)/%.o: %.cxx
+       $(CXX_WIN) $(CFLAGS_RELEASE_WIN) $(INC_RELEASE_WIN) -c $< -D_RELEASE -o $@
+
+clean_release_windows:
+       rm -f $(OBJ_RELEASE_WIN) $(OUT_RELEASE_WIN)/$(PROJNAME).exe
+       rm -rf $(OUT_RELEASE_WIN)
+       rm -rf $(OBJDIR_RELEASE_WIN)
+
+.PHONY: before_debug_linux out_debug_linux after_debug_linux before_release_linux out_release_linux after_release_linux before_debug_windows out_debug_windows after_debug_windows before_release_windows out_release_windows after_release_windows
diff --git a/examples/audio2/ao_example.cxx b/examples/audio2/ao_example.cxx
new file mode 100644 (file)
index 0000000..e22815c
--- /dev/null
@@ -0,0 +1,99 @@
+#include <ao/ao.h>
+#include <sndfile.h>
+#include <signal.h>
+
+#define BUFFER_SIZE 8192
+
+int cancel_playback;
+
+void on_cancel_playback(int sig) {
+    if (sig != SIGINT) {
+        return;
+    }
+
+    cancel_playback = 1;
+    exit(0);
+}
+
+static void clean(ao_device *device, SNDFILE *file) {
+    ao_close(device);
+    sf_close(file);
+    ao_shutdown();
+}
+
+int main() {
+    ao_device *device;
+    ao_sample_format format;
+    SF_INFO sfinfo;
+
+    int default_driver;
+
+    short *buffer;
+
+    signal(SIGINT, on_cancel_playback);
+
+
+    SNDFILE *file = sf_open("test.wav", SFM_READ, &sfinfo);
+
+    printf("Samples: %d\n", sfinfo.frames);
+    printf("Sample rate: %d\n", sfinfo.samplerate);
+    printf("Channels: %d\n", sfinfo.channels);
+
+    ao_initialize();
+
+    default_driver = ao_default_driver_id();
+
+    switch (sfinfo.format & SF_FORMAT_SUBMASK) {
+        case SF_FORMAT_PCM_16:
+            format.bits = 16;
+            break;
+        case SF_FORMAT_PCM_24:
+            format.bits = 24;
+            break;
+        case SF_FORMAT_PCM_32:
+            format.bits = 32;
+            break;
+        case SF_FORMAT_PCM_S8:
+            format.bits = 8;
+            break;
+        case SF_FORMAT_PCM_U8:
+            format.bits = 8;
+            break;
+        default:
+            format.bits = 16;
+            break;
+    }
+
+    format.channels = sfinfo.channels;
+    format.rate = sfinfo.samplerate;
+    format.byte_format = AO_FMT_NATIVE;
+    format.matrix = 0;
+
+    device = ao_open_live(default_driver, &format, NULL);
+
+    if (device == NULL) {
+        fprintf(stderr, "Error opening device.\n");
+        return 1;
+    }
+
+    buffer = (short*)calloc(BUFFER_SIZE, sizeof(short));
+
+    while (1) {
+        int read = sf_read_short(file, buffer, BUFFER_SIZE);
+
+        if (ao_play(device, (char *) buffer, (uint_32) (read * sizeof(short))) == 0) {
+            printf("ao_play: failed.\n");
+            clean(device, file);
+            break;
+        }
+
+        if (cancel_playback) {
+            clean(device, file);
+            break;
+        }
+    }
+
+    clean(device, file);
+
+    return 0;
+}
\ No newline at end of file
diff --git a/examples/audio2/test.wav b/examples/audio2/test.wav
new file mode 100644 (file)
index 0000000..df9f033
Binary files /dev/null and b/examples/audio2/test.wav differ
index f8e806c..3e0f771 100644 (file)
@@ -15,7 +15,7 @@ unpack:
 .PHONY: windows
 windows:
        cd $(WORKDIR)/fltk-1.3.4-1; \
-       ./configure CFLAGS="-m32 -mwindows" CXXFLAGS="-m32 -mwindows" LDFLAGS="-m32 -static -static-libgcc -static-libstdc++ -lpthread" --host=i686-w64-mingw32 --enable-cygwin --enable-localjpeg --enable-localzlib --enable-localpng --disable-xcursor --disable-xinerama --disable-xft --disable-xdbe --disable-xrender --disable-xfixes; \
+       ./configure CFLAGS="-m32 -mwindows" CXXFLAGS="-m32 -mwindows" LDFLAGS="-m32 -static -static-libgcc -static-libstdc++ -lpthread" --enable-static --host=i686-w64-mingw32 --enable-cygwin --enable-localjpeg --enable-localzlib --enable-localpng --disable-xcursor --disable-xinerama --disable-xft --disable-xdbe --disable-xrender --disable-xfixes; \
        make -j4
        mkdir -p $(WORKDIR)/../../include
        mkdir -p $(WORKDIR)/../../lib/mingw32
@@ -25,7 +25,7 @@ windows:
 .PHONY: linux
 linux:
        cd $(WORKDIR)/fltk-1.3.4-1; \
-       ./configure CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32 -static-libgcc -static-libstdc++" --enable-localjpeg --enable-localzlib --enable-localpng --disable-xcursor --disable-xinerama --disable-xft --disable-xdbe --disable-xrender --disable-xfixes; \
+       ./configure CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32 -static-libgcc -static-libstdc++" --enable-static --enable-localjpeg --enable-localzlib --enable-localpng --disable-xcursor --disable-xinerama --disable-xft --disable-xdbe --disable-xrender --disable-xfixes; \
        make -j4
        mkdir -p $(WORKDIR)/../../include
        mkdir -p $(WORKDIR)/../../lib/linux32
diff --git a/packages/libao/.gitignore b/packages/libao/.gitignore
new file mode 100644 (file)
index 0000000..3a0c00e
--- /dev/null
@@ -0,0 +1,7 @@
+# Ignore everything
+*
+
+# But not these files...
+!.gitignore
+!libao-1.2.2.tar.gz
+!Makefile
\ No newline at end of file
index 43a91cd..fdb90a2 100644 (file)
@@ -6,7 +6,7 @@
 ############################################################################
 WORKDIR = $(shell pwd)
 
-all: unpack windows clean linux
+all: unpack windows
 
 .PHONY: unpack
 unpack:
@@ -27,7 +27,7 @@ windows:
 linux:
        cd $(WORKDIR)/libao-1.2.2; \
        autogen.sh; \
-       ./configure CFLAGS="-m32 -static" CXXFLAGS="-m32 -static" LDFLAGS="-m32 -static -static-libgcc -static-libstdc++" --enable-static --enable-pulse --enable-alsa --enable-alsa-mmap; \
+       ./configure CFLAGS='-m32 -static -static-libgcc -static-libstdc++' --enable-static --enable-pulse --enable-alsa --enable-alsa-mmap; \
        sed -i -e 's/@HAVE_ALSA_TRUE@//g' $(WORKDIR)/libao-1.2.2/src/plugins/alsa/Makefile.in; \
        sed -i -e 's/@HAVE_ALSA_FALSE@//g' $(WORKDIR)/libao-1.2.2/src/plugins/alsa/Makefile.in; \
        make -j4
@@ -35,6 +35,8 @@ linux:
        mkdir -p $(WORKDIR)/../../lib/linux32
        cp -rf $(WORKDIR)/libao-1.2.2/include/ao $(WORKDIR)/../../include
        cp -rf $(WORKDIR)/libao-1.2.2/src/.libs/libao.a $(WORKDIR)/../../lib/linux32
+       cp -rf $(WORKDIR)/libao-1.2.2/src/plugins/pulse/.libs/libpulse.a $(WORKDIR)/../../lib/linux32
+       cp -rf $(WORKDIR)/libao-1.2.2/src/plugins/alsa/.libs/libalsa.a $(WORKDIR)/../../lib/linux32
 
 .PHONY: clean
 clean:
diff --git a/packages/libsndfile/.gitignore b/packages/libsndfile/.gitignore
new file mode 100644 (file)
index 0000000..252ef37
--- /dev/null
@@ -0,0 +1,7 @@
+# Ignore everything
+*
+
+# But not these files...
+!.gitignore
+!libsndfile-1.0.28.tar.gz
+!Makefile
\ No newline at end of file
diff --git a/packages/libsndfile/Makefile b/packages/libsndfile/Makefile
new file mode 100644 (file)
index 0000000..460fdb8
--- /dev/null
@@ -0,0 +1,42 @@
+############################################################################
+# Workfile: Makefile
+# Author: Daniel Giritzer, S1810567004 (daniel@giritzer.eu)
+# Date: 03.12.2018
+# Description: Universal Makefile for Unix based Operating Systems
+############################################################################
+WORKDIR = $(shell pwd)
+
+all: unpack windows clean linux
+
+.PHONY: unpack
+unpack:
+       tar xvzf libsndfile-1.0.28.tar.gz
+
+.PHONY: windows
+windows:
+       cd $(WORKDIR)/libsndfile-1.0.28; \
+       autoreconf -vfi; \
+       ./configure CFLAGS="-m32 -mconsole" CXXFLAGS="-m32 -mconsole" LDFLAGS="-m32 -static-libgcc -static-libstdc++ -lpthread" --host=i686-w64-mingw32; \
+       make -j4
+       mkdir -p $(WORKDIR)/../../include
+       mkdir -p $(WORKDIR)/../../lib/mingw32
+       cp -rf $(WORKDIR)/libsndfile-1.0.28/src/sndfile.h $(WORKDIR)/../../include
+       cp -rf $(WORKDIR)/libsndfile-1.0.28/src/.libs/libsndfile.a $(WORKDIR)/../../lib/mingw32
+       cp -rf $(WORKDIR)/libsndfile-1.0.28/src/.libs/libcommon.a $(WORKDIR)/../../lib/mingw32
+
+.PHONY: linux
+linux:
+       cd $(WORKDIR)/libsndfile-1.0.28; \
+       autoreconf -vfi; \
+       ./configure CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32 -static -static-libgcc -static-libstdc++"; \
+       make -j4
+       mkdir -p $(WORKDIR)/../../include
+       mkdir -p $(WORKDIR)/../../lib/linux32
+       cp -rf $(WORKDIR)/libsndfile-1.0.28/src/sndfile.h $(WORKDIR)/../../include
+       cp -rf $(WORKDIR)/libsndfile-1.0.28/src/.libs/libsndfile.a $(WORKDIR)/../../lib/linux32
+       cp -rf $(WORKDIR)/libsndfile-1.0.28/src/.libs/libcommon.a $(WORKDIR)/../../lib/linux32
+
+.PHONY: clean
+clean:
+       cd $(WORKDIR)/libsndfile-1.0.28; \
+       make clean
diff --git a/packages/libsndfile/libsndfile-1.0.28.tar.gz b/packages/libsndfile/libsndfile-1.0.28.tar.gz
new file mode 100644 (file)
index 0000000..a184f3b
Binary files /dev/null and b/packages/libsndfile/libsndfile-1.0.28.tar.gz differ