Example #1
0
int main(int argc, char** argv)
{
  ga_Format fmt;
  ga_Device* dev;
  gc_int16* buf;
  gc_int32 numSamples;
  gc_int32 sampleSize;
  gc_int32 numToQueue;
  gc_int32 i;
  gc_int16 sample;
  gc_float32 pan = 1.0f;
  gc_float32 t = 0.0f;

  /* Initialize library + device */
  gc_initialize(0);
  memset(&fmt, 0, sizeof(ga_Format));
  fmt.bitsPerSample = 16;
  fmt.numChannels = 2;
  fmt.sampleRate = 44100;
  numSamples = 2048;
  sampleSize = ga_format_sampleSize(&fmt);
  dev = ga_device_open(GA_DEVICE_TYPE_DEFAULT, 2, 2048, &fmt);
  if(!dev)
    return 1;

  /* Allocate buffer */
  buf = (gc_int16*)malloc(numSamples * sampleSize);

  /* Infinite mix loop */
  while(1)
  {
    numToQueue = ga_device_check(dev);
    while(numToQueue--)
    {
      for(i = 0; i < numSamples * 2; i = i + 2)
      {
        sample = (gc_int16)(sin(t) * 32768);
        sample = (sample > -32768 ? (sample < 32767 ? sample : 32767) : -32768);
        pan = (gc_float32)sin(t / 300) / 2.0f + 0.5f;
        buf[i] = (gc_int16)(sample * pan);
        buf[i + 1] = (gc_int16)(sample * (1.0f - pan));
        t = t + 0.03f;
        if(t > 3.14159265f)
          t -= 3.14159265f;
      }
      ga_device_queue(dev, (char*)buf);
    }
  }

  /* Clean up device + library */
  ga_device_close(dev);
  gc_shutdown();

  /* Free buffer */
  free(buf);

  return 0;
}
Example #2
0
	void SoundManager::init()
	{
#ifdef SPARKY_EMSCRIPTEN
#else
		gc_initialize(0);
		m_Manager = gau_manager_create();
		m_Mixer = gau_manager_mixer(m_Manager);
#endif
	}
Example #3
0
int main(int argc, char *argv[])
{
    stack_bottom = malloc(default_stack_size);
    memset(stack_bottom, 0xcc, default_stack_size);
    gc_initialize(default_heap_size);

    rtldDefault = dlopen(0, RTLD_NOW | RTLD_GLOBAL);

    print(call_scheme());

    printf("\n");
    return 0;
}
Example #4
0
int main(int argc, char *argv[])
{
    stack_bottom = malloc(DEFAULT_STACK_SIZE);
    memset(stack_bottom, 0xcc, DEFAULT_STACK_SIZE);

#ifdef HEAP_SIZE
    unsigned int heap_size = HEAP_SIZE;
#else
    unsigned int heap_size = DEFAULT_HEAP_SIZE;
#endif
    gc_initialize(heap_size);

    rtldDefault = dlopen(0, RTLD_NOW | RTLD_GLOBAL);

    print(call_scheme());

    printf("\n");
    return 0;
}
Example #5
0
int main(int argc, char** argv)
{
  gau_Manager* mgr;
  ga_Mixer* mixer;
  ga_Sound* sound;
  ga_Handle* handle;
  gau_SampleSourceLoop* loopSrc = 0;
  gau_SampleSourceLoop** pLoopSrc = &loopSrc;
  gc_int32 loop = 0;
  gc_int32 quit = 0;

  /* Initialize library + manager */
  gc_initialize(0);
  mgr = gau_manager_create();
  mixer = gau_manager_mixer(mgr);

  /* Create and play shared sound */
  if(!loop)
    pLoopSrc = 0;
  sound = gau_load_sound_file("test.wav", "wav");
  handle = gau_create_handle_sound(mixer, sound, &setFlagAndDestroyOnFinish, &quit, pLoopSrc);
  ga_handle_play(handle);

  /* Bounded mix/queue/dispatch loop */
  while(!quit)
  {
    gau_manager_update(mgr);
    printf("%d / %d\n", ga_handle_tell(handle, GA_TELL_PARAM_CURRENT), ga_handle_tell(handle, GA_TELL_PARAM_TOTAL));
    gc_thread_sleep(1);
  }

  /* Clean up sound */
  ga_sound_release(sound);

  /* Clean up library + manager */
  gau_manager_destroy(mgr);
  gc_shutdown();

  return 0;
}
Example #6
0
		void AudioManager::init() {
			gc_initialize(0);
			m_Manager = gau_manager_create();
		}