Changeset 32705 in project


Ignore:
Timestamp:
08/16/15 21:41:01 (5 years ago)
Author:
felix winkelmann
Message:

alut 0.9 (initial release separate from openal)

Location:
release/4/alut
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/4/alut/tags/0.9/alut.meta

    r32696 r32705  
    66 (doc-from-wiki)
    77 (needs easyffi make)
    8  (test-depends matchable)
     8 (test-depends matchable openal)
    99 (author "felix winkelmann")
    10  (files "alut.setup" "alut.release-info" "alut.meta" "alut.scm" "tests/run.scm" "tests/example.wav"))
     10 (files "alut.setup" "alut.release-info" "alut.meta" "alut.scm" "tests/run.scm"))
  • release/4/alut/tags/0.9/alut.scm

    r32696 r32705  
    33(module alut *
    44  (import scheme chicken foreign)
    5   (use easyffi openal al alc srfi-4)
     5  (use easyffi srfi-4)
    66
    77#>
    8 #ifdef C_MACOSX
    9 #include <OpenAL/alut.h>
    10 #else
    118#include <AL/alut.h>
    12 #endif
    139<#
    1410
     
    4642
    4743/** OpenAL 32bit type. */
    48 typedef unsigned int ALsizei;
     44typedef int ALsizei;
    4945
    5046/** OpenAL void type */
     
    5450typedef int ALenum;
    5551
    56 #define ALUTAPI
    57 #define ALUTAPIENTRY
     52#define ALUT_API
     53#define ALUT_APIENTRY
    5854
    59 ALUTAPI ALvoid  ALUTAPIENTRY alutInit(___in ALint *argc,___in char **argv);
    60 ALUTAPI ALvoid  ALUTAPIENTRY alutExit();
    61 ALUTAPI ALvoid  ALUTAPIENTRY alutUnloadWAV(ALenum format,ALvoid *data,ALsizei size,ALsizei freq);
     55ALUT_API ALboolean ALUT_APIENTRY alutInitWithoutContext (int *argcp, char **argv);
     56ALUT_API ALvoid ALUT_APIENTRY alutExit();
     57ALUT_API const char *ALUT_APIENTRY alutGetErrorString (ALenum error);
     58
     59ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFile (const char *fileName);
     60ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFileImage (const ALvoid *data, ALsizei length);
     61ALUT_API ALuint ALUT_APIENTRY alutCreateBufferHelloWorld (void);
     62ALUT_API ALuint ALUT_APIENTRY alutCreateBufferWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration);
     63
     64ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFile (const char *fileName,___out ALenum *format,___out ALsizei *size,___out ALfloat *frequency);
     65ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFileImage (const ALvoid *data, ALsizei length,___out ALenum *format,___out ALsizei *size,___out ALfloat *frequency);
     66ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryHelloWorld (___out ALenum *format,___out ALsizei *size,___out ALfloat *frequency);
     67ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration,___out ALenum *format,___out ALsizei *size,___out ALfloat *freq);
    6268
    6369EOF
    6470)
    6571
    66 #+macosx
    67 (foreign-parse #<<EOF
    68 ALUTAPI ALvoid  ALUTAPIENTRY alutLoadWAVFile(char *file,___out ALenum *format,___out ALvoid **data,___out ALsizei *size,___out ALsizei *freq);
    69 ALUTAPI ALvoid  ALUTAPIENTRY alutLoadWAVMemory(void *memory,___out ALenum *format,___out ALvoid **data,___out ALsizei *size,___out ALsizei *freq);
    70 
    71 
    72 EOF
    73 )
    74 
    75 #+(not macosx)
    76 (foreign-parse #<<EOF
    77 ALUTAPI ALvoid  ALUTAPIENTRY alutLoadWAVFile(char *file,___out ALenum *format,___out ALvoid **data,___out ALsizei *size,___out ALsizei *freq, ___out ALboolean *loop);
    78 ALUTAPI ALvoid  ALUTAPIENTRY alutLoadWAVMemory(void *memory,___out ALenum *format,___out ALvoid **data,___out ALsizei *size,___out ALsizei *freq, ___out ALboolean *loop);
    79 
    80 EOF
    81 )
    82 
    83 #+macosx
    84 (define alut:LoadWAVFile
    85   (let ((alut:LoadWAVFile alut:LoadWAVFile))
    86     (lambda (file)
    87       (let-values (((f d s fr) (alut:LoadWAVFile file)))
    88         (values f d s fr #f) ) ) ) )
    89 
    90 (declare (hide check))
    91 
    92 (define (check thunk #!optional (msg "OpenAL operation failed") . args)
    93   (al:GetError)
    94   (call-with-values thunk
    95     (lambda results
    96       (let ((err (al:GetError)))
    97         (unless (= err al:NO_ERROR)
    98           (abort
    99            (make-composite-condition
    100             (make-property-condition 'exn 'message msg 'arguments (if (pair? args) args (list err)))
    101             (make-property-condition 'openal 'class 'AL 'code err) ) ) ) )
    102         (apply values results) ) ) )
    103 
    104 (define (alut:load-buffer filename)
    105   (let-values (((format data size freq loop)
    106                 (check (cut alut:LoadWAVFile filename) "can not load WAV" filename) ) )
    107     (let ((v (make-u32vector 1)))
    108       (check (cut al:GenBuffers 1 v) "can not generate buffer for WAV" filename)
    109       (let ((buf (u32vector-ref v 0)))
    110         (check (cut al:BufferData buf format data size freq) "can not set buffer data for WAV" filename)
    111         (alut:UnloadWAV format data size freq)
    112         buf) ) ) )
    113 
    114 (apply alut:Init (receive (argc+argv)))
     72(alut:InitWithoutContext #f #f)
    11573
    11674)
  • release/4/alut/tags/0.9/alut.setup

    r32696 r32705  
    11;;;; alut.setup -*- Scheme -*-
    2 
    32
    43(use make)
    54
    6 (define *options*
    7   (cond-expand
    8    (macosx "-framework OpenAL -framework Foundation -D macosx")
    9    (else "-lopenal")))
    10 
    115(make (("alut.so" ("alut.scm")
    12         (run (csc -s alut.scm -O2 -d1 ,*options* -j alut)))
     6        (run (csc -s alut.scm -O2 -d1 -lalut -j alut)))
    137       ("alut.import.so" ("alut.so")
    148        (run (csc -s -O2 -d0 alut.import.scm))))
  • release/4/alut/tags/0.9/tests/run.scm

    r32696 r32705  
    1 (use al alc openal alut matchable srfi-18 extras)
     1(use openal al alc alut matchable srfi-18 extras)
    22
    33;; this code does no error checking
     4
     5(define (pause)
     6  (match (command-line-arguments)
     7    (("alut" ...)                       ; chicken-install -test
     8     (thread-join!
     9      (thread-start!
     10       (lambda ()
     11         (thread-sleep! 2)))))
     12    (_ (print "press RETURN to continue.")
     13       (read-line))))
    414
    515(define device (alc:OpenDevice #f))
     
    818(alc:MakeContextCurrent context)
    919
    10 (define buf1 (alut:load-buffer "example.wav"))
     20(define buf1 (alut:CreateBufferHelloWorld))
    1121(define source1 (openal:make-source buf1))
    1222
    1323(al:Sourcei source1 al:LOOPING 1)
    1424(al:SourcePlay source1)
    15 
    16 (match (command-line-arguments)
    17   (("alut" _)                   ; chicken-install -test
    18    (thread-start!
    19     (lambda ()
    20       (thread-sleep! 5)
    21       (exit))))
    22   (_ (print "press RETURN to continue.")
    23      (read-line)))
     25(pause)
    2426
    2527(alc:MakeContextCurrent #f)
  • release/4/alut/trunk/alut.meta

    r32696 r32705  
    66 (doc-from-wiki)
    77 (needs easyffi make)
    8  (test-depends matchable)
     8 (test-depends matchable openal)
    99 (author "felix winkelmann")
    10  (files "alut.setup" "alut.release-info" "alut.meta" "alut.scm" "tests/run.scm" "tests/example.wav"))
     10 (files "alut.setup" "alut.release-info" "alut.meta" "alut.scm" "tests/run.scm"))
  • release/4/alut/trunk/alut.scm

    r32696 r32705  
    33(module alut *
    44  (import scheme chicken foreign)
    5   (use easyffi openal al alc srfi-4)
     5  (use easyffi srfi-4)
    66
    77#>
    8 #ifdef C_MACOSX
    9 #include <OpenAL/alut.h>
    10 #else
    118#include <AL/alut.h>
    12 #endif
    139<#
    1410
     
    4642
    4743/** OpenAL 32bit type. */
    48 typedef unsigned int ALsizei;
     44typedef int ALsizei;
    4945
    5046/** OpenAL void type */
     
    5450typedef int ALenum;
    5551
    56 #define ALUTAPI
    57 #define ALUTAPIENTRY
     52#define ALUT_API
     53#define ALUT_APIENTRY
    5854
    59 ALUTAPI ALvoid  ALUTAPIENTRY alutInit(___in ALint *argc,___in char **argv);
    60 ALUTAPI ALvoid  ALUTAPIENTRY alutExit();
    61 ALUTAPI ALvoid  ALUTAPIENTRY alutUnloadWAV(ALenum format,ALvoid *data,ALsizei size,ALsizei freq);
     55ALUT_API ALboolean ALUT_APIENTRY alutInitWithoutContext (int *argcp, char **argv);
     56ALUT_API ALvoid ALUT_APIENTRY alutExit();
     57ALUT_API const char *ALUT_APIENTRY alutGetErrorString (ALenum error);
     58
     59ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFile (const char *fileName);
     60ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFileImage (const ALvoid *data, ALsizei length);
     61ALUT_API ALuint ALUT_APIENTRY alutCreateBufferHelloWorld (void);
     62ALUT_API ALuint ALUT_APIENTRY alutCreateBufferWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration);
     63
     64ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFile (const char *fileName,___out ALenum *format,___out ALsizei *size,___out ALfloat *frequency);
     65ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFileImage (const ALvoid *data, ALsizei length,___out ALenum *format,___out ALsizei *size,___out ALfloat *frequency);
     66ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryHelloWorld (___out ALenum *format,___out ALsizei *size,___out ALfloat *frequency);
     67ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration,___out ALenum *format,___out ALsizei *size,___out ALfloat *freq);
    6268
    6369EOF
    6470)
    6571
    66 #+macosx
    67 (foreign-parse #<<EOF
    68 ALUTAPI ALvoid  ALUTAPIENTRY alutLoadWAVFile(char *file,___out ALenum *format,___out ALvoid **data,___out ALsizei *size,___out ALsizei *freq);
    69 ALUTAPI ALvoid  ALUTAPIENTRY alutLoadWAVMemory(void *memory,___out ALenum *format,___out ALvoid **data,___out ALsizei *size,___out ALsizei *freq);
    70 
    71 
    72 EOF
    73 )
    74 
    75 #+(not macosx)
    76 (foreign-parse #<<EOF
    77 ALUTAPI ALvoid  ALUTAPIENTRY alutLoadWAVFile(char *file,___out ALenum *format,___out ALvoid **data,___out ALsizei *size,___out ALsizei *freq, ___out ALboolean *loop);
    78 ALUTAPI ALvoid  ALUTAPIENTRY alutLoadWAVMemory(void *memory,___out ALenum *format,___out ALvoid **data,___out ALsizei *size,___out ALsizei *freq, ___out ALboolean *loop);
    79 
    80 EOF
    81 )
    82 
    83 #+macosx
    84 (define alut:LoadWAVFile
    85   (let ((alut:LoadWAVFile alut:LoadWAVFile))
    86     (lambda (file)
    87       (let-values (((f d s fr) (alut:LoadWAVFile file)))
    88         (values f d s fr #f) ) ) ) )
    89 
    90 (declare (hide check))
    91 
    92 (define (check thunk #!optional (msg "OpenAL operation failed") . args)
    93   (al:GetError)
    94   (call-with-values thunk
    95     (lambda results
    96       (let ((err (al:GetError)))
    97         (unless (= err al:NO_ERROR)
    98           (abort
    99            (make-composite-condition
    100             (make-property-condition 'exn 'message msg 'arguments (if (pair? args) args (list err)))
    101             (make-property-condition 'openal 'class 'AL 'code err) ) ) ) )
    102         (apply values results) ) ) )
    103 
    104 (define (alut:load-buffer filename)
    105   (let-values (((format data size freq loop)
    106                 (check (cut alut:LoadWAVFile filename) "can not load WAV" filename) ) )
    107     (let ((v (make-u32vector 1)))
    108       (check (cut al:GenBuffers 1 v) "can not generate buffer for WAV" filename)
    109       (let ((buf (u32vector-ref v 0)))
    110         (check (cut al:BufferData buf format data size freq) "can not set buffer data for WAV" filename)
    111         (alut:UnloadWAV format data size freq)
    112         buf) ) ) )
    113 
    114 (apply alut:Init (receive (argc+argv)))
     72(alut:InitWithoutContext #f #f)
    11573
    11674)
  • release/4/alut/trunk/alut.setup

    r32696 r32705  
    11;;;; alut.setup -*- Scheme -*-
    2 
    32
    43(use make)
    54
    6 (define *options*
    7   (cond-expand
    8    (macosx "-framework OpenAL -framework Foundation -D macosx")
    9    (else "-lopenal")))
    10 
    115(make (("alut.so" ("alut.scm")
    12         (run (csc -s alut.scm -O2 -d1 ,*options* -j alut)))
     6        (run (csc -s alut.scm -O2 -d1 -lalut -j alut)))
    137       ("alut.import.so" ("alut.so")
    148        (run (csc -s -O2 -d0 alut.import.scm))))
  • release/4/alut/trunk/tests/run.scm

    r32696 r32705  
    1 (use al alc openal alut matchable srfi-18 extras)
     1(use openal al alc alut matchable srfi-18 extras)
    22
    33;; this code does no error checking
     4
     5(define (pause)
     6  (match (command-line-arguments)
     7    (("alut" ...)                       ; chicken-install -test
     8     (thread-join!
     9      (thread-start!
     10       (lambda ()
     11         (thread-sleep! 2)))))
     12    (_ (print "press RETURN to continue.")
     13       (read-line))))
    414
    515(define device (alc:OpenDevice #f))
     
    818(alc:MakeContextCurrent context)
    919
    10 (define buf1 (alut:load-buffer "example.wav"))
     20(define buf1 (alut:CreateBufferHelloWorld))
    1121(define source1 (openal:make-source buf1))
    1222
    1323(al:Sourcei source1 al:LOOPING 1)
    1424(al:SourcePlay source1)
    15 
    16 (match (command-line-arguments)
    17   (("alut" _)                   ; chicken-install -test
    18    (thread-start!
    19     (lambda ()
    20       (thread-sleep! 5)
    21       (exit))))
    22   (_ (print "press RETURN to continue.")
    23      (read-line)))
     25(pause)
    2426
    2527(alc:MakeContextCurrent #f)
Note: See TracChangeset for help on using the changeset viewer.