comparison app_wrapper/app_main.h @ 0:4606bd505630 tip

first import
author Fiore Martin <f.martin@qmul.ac.uk>
date Sat, 13 Jun 2015 15:08:10 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4606bd505630
1 #ifndef _IPLUGAPP_APP_MAIN_H_
2 #define _IPLUGAPP_APP_MAIN_H_
3
4 #include "IPlugOSDetect.h"
5
6 /*
7
8 Standalone osx/win app wrapper for iPlug, using SWELL
9 Oli Larkin 2012
10
11 Notes:
12
13 App settings are stored in a .ini file. The location is as follows:
14
15 Windows7: C:\Users\USERNAME\AppData\Local\AccessiblePeakMeter\settings.ini
16 Windows XP/Vista: C:\Documents and Settings\USERNAME\Local Settings\Application Data\AccessiblePeakMeter\settings.ini
17 OSX: /Users/USERNAME/Library/Application\ Support/AccessiblePeakMeter/settings.ini
18
19 */
20
21 #ifdef OS_WIN
22 #include <windows.h>
23 #include <commctrl.h>
24
25 #define DEFAULT_INPUT_DEV "Default Device"
26 #define DEFAULT_OUTPUT_DEV "Default Device"
27
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) )
33
34 #define DEFAULT_INPUT_DEV "Built-in Input"
35 #define DEFAULT_OUTPUT_DEV "Built-in Output"
36
37 #define DAC_COREAUDIO 0
38 // #define DAC_JACK 1
39 #endif
40
41 #include "wdltypes.h"
42 #include "RtAudio.h"
43 #include "RtMidi.h"
44 #include <string>
45 #include <vector>
46
47 #include "../AccessiblePeakMeter.h" // change this to match your iplug plugin .h file
48
49 typedef unsigned short UInt16;
50
51 struct AppState
52 {
53 // on osx core audio 0 or jack 1
54 // on windows DS 0 or ASIO 1
55 UInt16 mAudioDriverType;
56
57 // strings
58 char mAudioInDev[100];
59 char mAudioOutDev[100];
60 char mAudioSR[100];
61 char mAudioIOVS[100];
62 char mAudioSigVS[100];
63
64 UInt16 mAudioInChanL;
65 UInt16 mAudioInChanR;
66 UInt16 mAudioOutChanL;
67 UInt16 mAudioOutChanR;
68 UInt16 mAudioInIsMono;
69
70 // strings containing the names of the midi devices
71 char mMidiInDev[100];
72 char mMidiOutDev[100];
73
74 UInt16 mMidiInChan;
75 UInt16 mMidiOutChan;
76
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)
85 {
86 strcpy(mAudioInDev, DEFAULT_INPUT_DEV);
87 strcpy(mAudioOutDev, DEFAULT_OUTPUT_DEV);
88 strcpy(mAudioSR, "44100");
89 strcpy(mAudioIOVS, "512");
90 strcpy(mAudioSigVS, "32");
91
92 strcpy(mMidiInDev, "off");
93 strcpy(mMidiOutDev, "off");
94 }
95 };
96
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
103
104 extern std::string GetAudioDeviceName(int idx);
105 extern int GetAudioDeviceID(char* deviceNameToTest);
106
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
115 );
116
117 extern bool AudioSettingsInStateAreEqual(AppState* os, AppState* ns);
118 extern bool MIDISettingsInStateAreEqual(AppState* os, AppState* ns);
119
120 extern bool TryToChangeAudioDriverType();
121 extern bool TryToChangeAudio();
122 extern bool ChooseMidiInput(const char* pPortName);
123 extern bool ChooseMidiOutput(const char* pPortName);
124
125 extern bool AttachGUI();
126
127 extern RtAudio* gDAC;
128 extern RtMidiIn *gMidiIn;
129 extern RtMidiOut *gMidiOut;
130
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
134
135 extern unsigned int gSigVS;
136 extern unsigned int gBufIndex; // index for signal vector, loops from 0 to gSigVS
137
138 extern char *gINIPath; // path of ini file
139 extern void UpdateINI();
140
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;
145
146 #endif //_IPLUGAPP_APP_MAIN_H_
147