Advertisement
Kaelygon

ukaelTypedefC.h

Jul 8th, 2023
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.09 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <stdio.h>
  4. #include <stdint.h>
  5. #include <stdlib.h>
  6.  
  7. //portAudio
  8. static const uint16_t SAMPLE_RATE = 32768;
  9. static const uint16_t FRAMES_PER_BUFFER = 64;
  10.  
  11. //ukael
  12. static const uint8_t DEFAULT_AMPLITUDE = 128;
  13. static const uint32_t BUFFER_SIZE = (2<<18); //Size of the audio buffer
  14. static const uint8_t MAX_CHANNELS = 1;
  15.  
  16.  
  17. //AudioData (data*, size, position)
  18. typedef struct {
  19.     uint8_t* data;  // Pointer to the raw audio data
  20.     size_t size;         // AudioData sample count
  21.     size_t position;      // Current position in the audio data
  22. } AudioData;
  23.  
  24.  
  25. //typedef
  26. //fraction (a, b)
  27. typedef struct {
  28.     uint16_t a;
  29.     uint16_t b;
  30. } Frac;
  31.  
  32.  
  33. //wave arguments (uint32_t time, frac, u8arg, u16arg)
  34. typedef struct{
  35.     uint32_t    time;           //uint16_t time
  36.     Frac        freq;           //Frac{frac.a,frac.b}
  37.     uint8_t     u8arg[4];       //uint8_t u8arg[4]
  38.     uint16_t    u16arg[4];      //uint16_t u16arg[4]
  39. } WaveArg;
  40.  
  41.  
  42. //wave function wrapper
  43. typedef uint8_t (*ukaelWave)(WaveArg *arg);
  44.  
  45. // WaveMap (const char* id, WaveArg args)
  46. typedef struct {
  47.     const char* id;
  48.     ukaelWave waveFunc;
  49. } WaveMap;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement