audio: Made DirectBuffer API public and now import EcereAudio from DirectBufferPlayer
authorJerome St-Louis <jerome@ecere.com>
Tue, 23 Aug 2011 02:43:47 +0000 (22:43 -0400)
committerJerome St-Louis <jerome@ecere.com>
Tue, 23 Aug 2011 02:43:47 +0000 (22:43 -0400)
extras/audio/alsa.ec
extras/audio/dsound.ec
extras/audio/mixer.ec
samples/audio/DirectBufferPlayer/WavPlayer.epj
samples/audio/DirectBufferPlayer/wavPlayer.ec
samples/audio/PlaySound/PlaySound.epj

index a92b233..cadd3ae 100644 (file)
@@ -18,12 +18,12 @@ static snd_mixer_t *mixer_handle;
 
 static double volume, balance;
 
-void AudioSetBalance(double percent)
+public void AudioSetBalance(double percent)
 {
    balance = percent;
 }
 
-bool AudioSetVolume(VolumeControl type, double percent)
+public bool AudioSetVolume(VolumeControl type, double percent)
 {
    bool result = false;
    if(type == application)
@@ -62,7 +62,7 @@ bool AudioSetVolume(VolumeControl type, double percent)
    return result;
 }
 
-bool AudioGetVolume(VolumeControl type, double * percent)
+public bool AudioGetVolume(VolumeControl type, double * percent)
 {
    bool result = false;
    if(type == application)
@@ -101,19 +101,19 @@ bool AudioGetVolume(VolumeControl type, double * percent)
    return result;
 }
 
-void OpenMixer()
+public void OpenMixer()
 {
    snd_mixer_open(&mixer_handle, 0);
    snd_mixer_attach(mixer_handle, "default");
        snd_mixer_selem_register(mixer_handle, null, null);
 }
 
-void CloseMixer()
+public void CloseMixer()
 {
    snd_mixer_close(mixer_handle);
 }
 
-int OpenAudio(AudioSpec wanted, AudioSpec result)
+public int OpenAudio(AudioSpec wanted, AudioSpec result)
 {
    int err;
    unsigned int i;
@@ -145,7 +145,7 @@ int OpenAudio(AudioSpec wanted, AudioSpec result)
    return 1;
 }
 
-void PauseAudio(int value)
+public void PauseAudio(int value)
 {
    if(!value)
    {
@@ -153,7 +153,7 @@ void PauseAudio(int value)
    }
 }
 
-void CloseAudio()
+public void CloseAudio()
 {
    soundThread.done = true;
    soundThread.Wait();
index 0521c47..51b0659 100644 (file)
@@ -21,7 +21,7 @@
 
 import "audio"
 
-void AudioSetBalance(double percent)
+public void AudioSetBalance(double percent)
 {
    if(streamingSound)
       streamingSound.balance = percent;
@@ -30,7 +30,7 @@ void AudioSetBalance(double percent)
 static HWAVEOUT hWaveOut;
 static HMIXEROBJ hmx;
 
-void OpenMixer()
+public void OpenMixer()
 {
    HMIXER        mixerHandle;
    WAVEFORMATEX  waveFormat = { 0 };
@@ -46,13 +46,13 @@ void OpenMixer()
    mixerOpen((HMIXER *)&hmx, (uint)hWaveOut, 0, 0, MIXER_OBJECTF_HWAVEOUT);
 }
 
-void CloseMixer()
+public void CloseMixer()
 {
    mixerClose((HMIXER)hmx);
    waveOutClose(hWaveOut);
 }
 
-bool AudioSetVolume(VolumeControl type, double percent)
+public bool AudioSetVolume(VolumeControl type, double percent)
 {
    bool result = false;
    if(type == application)
@@ -102,7 +102,7 @@ bool AudioSetVolume(VolumeControl type, double percent)
    return result;
 }
 
-bool AudioGetVolume(VolumeControl type, double * percent)
+public bool AudioGetVolume(VolumeControl type, double * percent)
 {
    bool result = false;
    if(type == application)
@@ -151,7 +151,7 @@ bool AudioGetVolume(VolumeControl type, double * percent)
    return result;
 }
 
-int OpenAudio(AudioSpec wanted, AudioSpec result)
+public int OpenAudio(AudioSpec wanted, AudioSpec result)
 {
    #define NUM_PLAY_NOTIFICATIONS  16
    uint nBlockAlign, dwNotifySize;
@@ -183,7 +183,7 @@ int OpenAudio(AudioSpec wanted, AudioSpec result)
    return 0;
 }
 
-void PauseAudio(int value)
+public void PauseAudio(int value)
 {
    if(!value)
    {
@@ -192,7 +192,7 @@ void PauseAudio(int value)
    }
 }
 
-void CloseAudio()
+public void CloseAudio()
 {
    if(dSoundThread)
    {
index d1cd024..e6d653e 100644 (file)
@@ -3,8 +3,8 @@ import "audio"
 
 #include <string.h>
 
-// define AUDIO_BUFFER_SIZE = 21024;
-define AUDIO_BUFFER_SIZE = 48000;
+// public define AUDIO_BUFFER_SIZE = 21024;
+public define AUDIO_BUFFER_SIZE = 48000;
 
 struct WAVEHDR
 {
index a5469f8..0bc1f93 100644 (file)
       }
    ],
    "Files" : [
-      {
-         "Folder" : "audio",
-         "Files" : [
-            "../../../extras/audio/alsa.ec",
-            "../../../extras/audio/audio.ec",
-            "../../../extras/audio/dsound.ec"
-         ]
-      },
       "wavPlayer.ec"
    ],
    "ResourcesPath" : "",
index 929ad30..790e5fc 100644 (file)
@@ -1,67 +1,4 @@
-import "ecere"
-import "audio"
-
-#include <string.h>
-
-define AUDIO_BUFFER_SIZE = 21024;
-
-struct WAVEHDR
-{
-   byte   format[4]           __attribute__((packed));
-   uint32 f_len               __attribute__((packed));
-   byte   wave_fmt[8]         __attribute__((packed));
-   uint32 fmt_len             __attribute__((packed));
-   uint16 fmt_tag             __attribute__((packed));
-   uint16 channel             __attribute__((packed));
-   uint32 samples_per_sec     __attribute__((packed));
-   uint32 avg_bytes_per_sec   __attribute__((packed));
-   uint16 blk_align           __attribute__((packed));
-   uint16 bits_per_sample     __attribute__((packed));
-   byte   data[4]             __attribute__((packed));
-   uint32 data_len            __attribute__((packed));
-};
-
-public class Sound
-{
-public:
-   int frequency, bits, channels, length;
-   byte * data;
-
-   ~Sound()
-   {
-      delete data;
-   }
-
-   bool Load(char * fileName)
-   {
-      bool result = false;
-      WAVEHDR header;
-      File f = FileOpen(fileName, read);
-      if(f)
-      {
-         if(f.Read(header,sizeof(WAVEHDR),1) && !memcmp(header.format,"RIFF",4) && !memcmp(header.wave_fmt,"WAVEfmt ",8))
-         {
-            data = new byte[header.data_len];
-            if(data)
-            {
-               int c = f.Read(data, 1, header.data_len);
-               if(c)
-               {
-                  frequency = header.samples_per_sec;
-                  bits = header.bits_per_sample;
-                  channels = header.channel;
-                  length = Min(header.data_len, c);
-                  if(c < header.data_len)
-                     length -= 2048;
-                  result = true;
-               }
-            }
-         }
-         delete f;
-      }
-      return result;
-   }
-}
+import "EcereAudio"
 
 class Form1 : Window
 {
index 4ccc607..2538a43 100644 (file)
@@ -1,10 +1,12 @@
 {
    "Version" : 0.2,
-   "ModuleName" : "BitmapAudioKB",
+   "ModuleName" : "PlaySound",
+   "Description" : "",
+   "License" : "",
    "Options" : {
       "Warnings" : "All",
       "TargetType" : "Executable",
-      "TargetFileName" : "BitmapAudioKB",
+      "TargetFileName" : "PlaySound",
       "Libraries" : [
          "ecere"
       ]