ConvoEngine: Make max channel counts configurable.
[wdl/wdl-ol.git] / IPlugExamples / IPlugConvoEngine / app_wrapper / app_main.h
blob7723e23194a652efed4d21abce603d5f43bad29b
1 #ifndef _IPLUGAPP_APP_MAIN_H_
2 #define _IPLUGAPP_APP_MAIN_H_
4 #include "IPlugOSDetect.h"
6 /*
8 Standalone osx/win app wrapper for iPlug, using SWELL
9 Oli Larkin 2012
11 Notes:
13 App settings are stored in a .ini file. The location is as follows:
15 Windows7: C:\Users\USERNAME\AppData\Local\IPlugConvoEngine\settings.ini
16 Windows XP/Vista: C:\Documents and Settings\USERNAME\Local Settings\Application Data\IPlugConvoEngine\settings.ini
17 OSX: /Users/USERNAME/Library/Application\ Support/IPlugConvoEngine/settings.ini
21 #ifdef OS_WIN
22 #include <windows.h>
23 #include <commctrl.h>
25 #define DEFAULT_INPUT_DEV "Default Device"
26 #define DEFAULT_OUTPUT_DEV "Default Device"
28 #define DAC_DS 0
29 #define DAC_ASIO 1
30 #else if defined OS_OSX
31 #include "swell.h"
32 #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) )
34 #define DEFAULT_INPUT_DEV "Built-in Input"
35 #define DEFAULT_OUTPUT_DEV "Built-in Output"
37 #define DAC_COREAUDIO 0
38 // #define DAC_JACK 1
39 #endif
41 #include "wdltypes.h"
42 #include "RtAudio.h"
43 #include "RtMidi.h"
44 #include <string>
45 #include <vector>
47 #include "../IPlugConvoEngine.h" // change this to match your iplug plugin .h file
49 typedef unsigned short UInt16;
51 struct AppState
53 // on osx core audio 0 or jack 1
54 // on windows DS 0 or ASIO 1
55 UInt16 mAudioDriverType;
57 // strings
58 char mAudioInDev[100];
59 char mAudioOutDev[100];
60 char mAudioSR[100];
61 char mAudioIOVS[100];
62 char mAudioSigVS[100];
64 UInt16 mAudioInChanL;
65 UInt16 mAudioInChanR;
66 UInt16 mAudioOutChanL;
67 UInt16 mAudioOutChanR;
68 UInt16 mAudioInIsMono;
70 // strings containing the names of the midi devices
71 char mMidiInDev[100];
72 char mMidiOutDev[100];
74 UInt16 mMidiInChan;
75 UInt16 mMidiOutChan;
77 AppState():
78 mAudioDriverType(0), // DS / CoreAudio by default
79 mAudioInChanL(1),
80 mAudioInChanR(2),
81 mAudioOutChanL(1),
82 mAudioOutChanR(2),
83 mMidiInChan(0),
84 mMidiOutChan(0)
86 strcpy(mAudioInDev, DEFAULT_INPUT_DEV);
87 strcpy(mAudioOutDev, DEFAULT_OUTPUT_DEV);
88 strcpy(mAudioSR, "44100");
89 strcpy(mAudioIOVS, "512");
90 strcpy(mAudioSigVS, "32");
92 strcpy(mMidiInDev, "off");
93 strcpy(mMidiOutDev, "off");
97 extern WDL_DLGRET MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
98 extern WDL_DLGRET PreferencesDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
99 extern HINSTANCE gHINST;
100 extern HWND gHWND;
101 extern UINT gScrollMessage;
102 extern IPlug* gPluginInstance; // The iplug plugin instance
104 extern std::string GetAudioDeviceName(int idx);
105 extern int GetAudioDeviceID(char* deviceNameToTest);
107 extern void ProbeAudioIO();
108 extern bool InitialiseAudio(unsigned int inId,
109 unsigned int outId,
110 unsigned int sr,
111 unsigned int iovs,
112 unsigned int chnls,
113 unsigned int inChanL,
114 unsigned int outChanL
117 extern bool AudioSettingsInStateAreEqual(AppState* os, AppState* ns);
118 extern bool MIDISettingsInStateAreEqual(AppState* os, AppState* ns);
120 extern bool TryToChangeAudioDriverType();
121 extern bool TryToChangeAudio();
122 extern bool ChooseMidiInput(const char* pPortName);
123 extern bool ChooseMidiOutput(const char* pPortName);
125 extern bool AttachGUI();
127 extern RtAudio* gDAC;
128 extern RtMidiIn *gMidiIn;
129 extern RtMidiOut *gMidiOut;
131 extern AppState *gState;
132 extern AppState *gTempState; // The state is copied here when the pref dialog is opened, and restored if cancel is pressed
133 extern AppState *gActiveState; // When the audio driver is started the current state is copied here so that if OK is pressed after APPLY nothing is changed
135 extern unsigned int gSigVS;
136 extern unsigned int gBufIndex; // index for signal vector, loops from 0 to gSigVS
138 extern char *gINIPath; // path of ini file
139 extern void UpdateINI();
141 extern std::vector<unsigned int> gAudioInputDevs;
142 extern std::vector<unsigned int> gAudioOutputDevs;
143 extern std::vector<std::string> gMIDIInputDevNames;
144 extern std::vector<std::string> gMIDIOutputDevNames;
146 #endif //_IPLUGAPP_APP_MAIN_H_