AUD_Special.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*******************************************************************************
  2. * Copyright 2009-2016 Jörg Müller
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. ******************************************************************************/
  16. #pragma once
  17. #include "AUD_Types.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * Returns information about a sound.
  23. * \param sound The sound to get the info about.
  24. * \return The AUD_SoundInfo structure with filled in data.
  25. */
  26. extern AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound);
  27. /**
  28. * Reads a sound file into a newly created float buffer.
  29. * The sound is therefore bandpassed, rectified and resampled.
  30. */
  31. extern AUD_API float* AUD_readSoundBuffer(const char* filename, float low, float high,
  32. float attack, float release, float threshold,
  33. int accumulate, int additive, int square,
  34. float sthreshold, double samplerate,
  35. int* length);
  36. /**
  37. * Pauses a playing sound after a specific amount of time.
  38. * \param handle The handle to the sound.
  39. * \param seconds The time in seconds.
  40. * \return The silence handle.
  41. */
  42. extern AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds);
  43. /**
  44. * Reads a sound into a buffer for drawing at a specific sampling rate.
  45. * \param sound The sound to read.
  46. * \param buffer The buffer to write to. Must have a size of 3*4*length.
  47. * \param length How many samples to read from the sound.
  48. * \param samples_per_second How many samples to read per second of the sound.
  49. * \return How many samples really have been read. Always <= length.
  50. */
  51. extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, short* interrupt);
  52. /**
  53. * Mixes a sound down into a file.
  54. * \param sound The sound scene to mix down.
  55. * \param start The start frame.
  56. * \param length The count of frames to write.
  57. * \param buffersize How many samples should be written at once.
  58. * \param filename The file to write to.
  59. * \param specs The file's audio specification.
  60. * \param format The file's container format.
  61. * \param codec The codec used for encoding the audio data.
  62. * \param bitrate The bitrate for encoding.
  63. * \return An error message or NULL in case of success.
  64. */
  65. extern AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length,
  66. unsigned int buffersize, const char* filename,
  67. AUD_DeviceSpecs specs, AUD_Container format,
  68. AUD_Codec codec, unsigned int bitrate);
  69. /**
  70. * Mixes a sound down into multiple files.
  71. * \param sound The sound scene to mix down.
  72. * \param start The start frame.
  73. * \param length The count of frames to write.
  74. * \param buffersize How many samples should be written at once.
  75. * \param filename The file to write to, the channel number and an underscore are added at the beginning.
  76. * \param specs The file's audio specification.
  77. * \param format The file's container format.
  78. * \param codec The codec used for encoding the audio data.
  79. * \param bitrate The bitrate for encoding.
  80. * \return An error message or NULL in case of success.
  81. */
  82. extern AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length,
  83. unsigned int buffersize, const char* filename,
  84. AUD_DeviceSpecs specs, AUD_Container format,
  85. AUD_Codec codec, unsigned int bitrate);
  86. /**
  87. * Opens a read device and prepares it for mixdown of the sound scene.
  88. * \param specs Output audio specifications.
  89. * \param sequencer The sound scene to mix down.
  90. * \param volume The overall mixdown volume.
  91. * \param start The start time of the mixdown in the sound scene.
  92. * \return The read device for the mixdown.
  93. */
  94. extern AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start);
  95. /**
  96. * Initializes audio routines (FFMPEG/JACK if it is enabled).
  97. */
  98. extern AUD_API void AUD_initOnce();
  99. /**
  100. * Unitinitializes an audio routines.
  101. */
  102. extern AUD_API void AUD_exitOnce();
  103. /**
  104. * Initializes an audio device.
  105. * \param device The device type that should be used.
  106. * \param specs The audio specification to be used.
  107. * \param buffersize The buffersize for the device.
  108. * \return Whether the device has been initialized.
  109. */
  110. extern AUD_API AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name);
  111. /**
  112. * Unitinitializes an audio device.
  113. * \param device The device to free.
  114. */
  115. extern AUD_API void AUD_exit(AUD_Device* device);
  116. /**
  117. * Retrieves available devices. Note that all memory returned has to be freed!
  118. */
  119. extern AUD_API char** AUD_getDeviceNames();
  120. #ifdef __cplusplus
  121. }
  122. #endif