HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AU_Input.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: AU_Input.h ( AU Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __AU_Input__
12 #define __AU_Input__
13 
14 #include "AU_API.h"
15 #include <UT/UT_AudioInput.h>
16 
17 #define AU_MAX_VOL_CHANNELS 4
18 
19 
20 #if defined(WIN32)
21  #include "AU_NTSystem.h"
22  class AU_API AU_Input : public UT_AudioInput, public AU_NTSystem
23 #elif defined(MBSD)
24  class AU_MBSDUtilAudioInfo;
25 
26  class AU_API AU_Input : public UT_AudioInput
27 #elif defined(LINUX)
28 
29  class AU_API AU_Input : public UT_AudioInput
30 #else
31  #error Unsupported platform
32 #endif
33 {
34 public:
35 
36  AU_Input(int channels, int rate);
37  ~AU_Input() override;
38 
39  int open(float queuesize) override;
40  void close() override;
41 
42  int hasInput() override;
43  short * getInput(int size) override;
44 
45  int getGlobalRate() override;
46 
47  int setSource(int source) override;
48  int getSource() override;
49 
50  int setMicrophoneMode(int stereo) override;
51  int getMicrophoneMode() override;
52  int getChannelMode() override;
53 
54  int setVolume(int speaker, float vol) override;
55  float getVolume(int speaker) override;
56 
57  UT_AudioInput * newAudioInputDevice(int channels, int rate) override;
58 
59 private:
60 #ifdef WIN32
61  // Creates a new wave header with its data block at pos in myQueue.
62  void appendWaveHeader(int pos);
63  // Apply volume adjustments, and copy 2 channels to 4 if required
64  void applyVolume(char *data, int bytesPerChannel);
65 
66  int myPort;
67 
68  // Specifies the input source.
69  int mySource;
70  // The size of each wave packet (in bytes).
71  int myBlockSize;
72  // The number of bytes copied from the last incomplete block.
73  int myBlockOffset;
74  // NT doesn't allow setting of input volume, so we fake it.
75  float myVolumes[4];
76 
77 #elif defined(MBSD)
78  // adjust the volume
79  void applyVolume(char *data, int data_size );
80 
81  AU_MBSDUtilAudioInfo * myInfo; // audio info (rate, buffers, etc).
82  int myRate; // sample rate
83  int myChannels; // number of channels
84  int mySource; // specifies the input source
85  float myVolumes[ AU_MAX_VOL_CHANNELS ]; // volumes per channel
86 
87 #elif defined(LINUX)
88  void adjustRate(int read);
89 
90  int myRate;
91  int myIsOpen;
92 
93 #else
94  #error Unsupported platform
95 #endif
96 };
97 
98 #endif
virtual float getVolume(int speaker)
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:623
virtual int setSource(int source)
virtual int setMicrophoneMode(int stereo)
virtual int hasInput()
virtual int getMicrophoneMode()
virtual int getSource()
virtual int getChannelMode()
virtual int setVolume(int speaker, float vol)
#define AU_API
Definition: AU_API.h:10
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
virtual UT_AudioInput * newAudioInputDevice(int channels, int rate)
~AU_Input() override
virtual short * getInput(int size)
GLsizeiptr size
Definition: glcorearb.h:664
virtual void close()
#define AU_MAX_VOL_CHANNELS
Definition: AU_Input.h:17
virtual int getGlobalRate()
virtual int open(float queuesize)
Definition: format.h:895
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)