LinJamConfig.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. ==============================================================================
  3. LinJamConfig.h
  4. Created: 12 Jun 2014 7:05:12am
  5. Author: me
  6. ==============================================================================
  7. */
  8. #ifndef _LINJAMCONFIG_H_
  9. #define _LINJAMCONFIG_H_
  10. #include "Constants.h"
  11. #include "JuceHeader.h"
  12. class LinJamConfig : public ValueTree::Listener , public Value::Listener
  13. {
  14. public:
  15. LinJamConfig() ;
  16. ~LinJamConfig() ;
  17. static String TrimStereoName(String channel_name) ;
  18. static ValueTree NewChannel( String channel_name = CONFIG::DEFAULT_CHANNEL_NAME ,
  19. int channel_idx = CONFIG::DEFAULT_CHANNEL_IDX ) ;
  20. // client config
  21. ValueTree client ;
  22. /* client-specfic data - access via this->client
  23. var save-multitrack-mode // int
  24. var save-mixdown-mode // int
  25. var should-save-log // bool
  26. var debug-level // int
  27. var should-hide-bots // bool
  28. */
  29. ValueTree subscriptions ;
  30. /* subscriptions-specfic data - access via this->subscriptions
  31. var subscribe-mode // int
  32. */
  33. // audio device config
  34. ValueTree audio ;
  35. /* audio-specfic data - access via this->audio
  36. var win-audio-if-n // int (audioStreamer::Interface enum)
  37. var asio-driver // int
  38. var asio-input0 // int
  39. var asio-input1 // int
  40. var asio-output0 // int
  41. var asio-output1 // int
  42. var ks-input // int
  43. var ks-output // int
  44. var ks-bit-depth // int
  45. var ks-sample-rate // int
  46. var ks-n-blocks // int
  47. var ks-block-size // int
  48. var ds-input0 // int
  49. var ds-input1 // int
  50. var ds-input2 // int
  51. var ds-input3 // int
  52. var ds-output0 // int
  53. var ds-output1 // int
  54. var ds-output2 // int
  55. var ds-output3 // int
  56. var ds-bit-depth // int
  57. var ds-sample-rate // int
  58. var ds-n-blocks // int
  59. var ds-block-size // int
  60. var wave-input // int
  61. var wave-output // int
  62. var wave-bit-depth // int
  63. var wave-sample-rate // int
  64. var wave-n-blocks // int
  65. var wave-block-size // int
  66. var mac-device-name // string
  67. var mac-n-inputs // int
  68. var mac-bit-depth // int
  69. var mac-sample-rate // int
  70. var nix-audio-if-n // int (audioStreamer::Interface enum)
  71. var jack-server // int
  72. var jack-name // string
  73. var jack-n-inputs // int
  74. var jack-n-outputs // int
  75. var alsa-config // string
  76. */
  77. // login config
  78. ValueTree server ;
  79. // per server config
  80. ValueTree servers ;
  81. /* transient login data - access through via this->server // TODO:: merge into <servers> (issue #33)
  82. /* per-server data - access through via this->servers
  83. var host // string
  84. var login // string
  85. var pass // string
  86. var is-anonymous // bool
  87. var should-agree // bool // TODO: unused
  88. var is-agreed // bool // TODO: <server> node only - this exists only so OnLicense doesnt block (issue #14)
  89. */
  90. // channels
  91. ValueTree masterChannels ; // children: master channel and metro channel as below
  92. ValueTree localChannels ; // children: channels as below
  93. ValueTree remoteUsers ; // children: users , grandchildren: channels as below
  94. /* per-user data - access via this->remoteUsers
  95. var user-idx // int
  96. /* per-channel data - access via masterChannels , localChannels , remoteUsers[A_USER]
  97. var channel-name // string
  98. var channel-idx // int
  99. var stereo-pair-idx // int
  100. var volume // double
  101. var pan // double
  102. var is-xmitrcv // bool
  103. var is-muted // bool
  104. var is-solo // bool
  105. var source-sink-n // int
  106. var stereo-status // int
  107. var vu-left // double
  108. var vu-right // double
  109. */
  110. // validation
  111. bool isConfigSane() ;
  112. String parseUsername( String user_name) ;
  113. Identifier makeHostId( String host_name) ;
  114. Identifier makeUserId( String channel_name) ;
  115. Identifier makeChannelId( int channel_idx) ;
  116. String makeStereoName( String channel_name , int stereo_status) ;
  117. int parseStereoStatus(String channel_name) ;
  118. void setStereo( ValueTree channel_store , int stereo_status) ;
  119. int setRemoteStereo( ValueTree user_store , ValueTree channel_store ,
  120. String prev_channel_name ) ;
  121. // getters/setters
  122. ValueTree addChannel( ValueTree channels_store , ValueTree new_store) ;
  123. void destroyChannel( ValueTree channels_store , ValueTree channel_store) ;
  124. ValueTree getOrAddRemoteUser( String user_name) ;
  125. ValueTree getOrAddRemoteChannel(Identifier user_id , String channel_name ,
  126. int channel_idx = CONFIG::DEFAULT_CHANNEL_IDX) ;
  127. ValueTree getUserById( Identifier user_id) ;
  128. ValueTree getChannelById( Identifier channels_id , Identifier channel_id) ;
  129. ValueTree getChannelByIdx( ValueTree channels_store , int channel_idx) ;
  130. ValueTree getChannelByPairIdx( ValueTree channels_store , int pair_idx) ;
  131. ValueTree getChannelByName( ValueTree channels_store , String channel_name) ;
  132. ValueTree getUserMasterChannel( ValueTree user_store) ;
  133. void setServer() ;
  134. ValueTree getServer( String host_name) ;
  135. void setCurrentServer( String host_name , String login , String pass ,
  136. bool is_anonymous ) ;
  137. ValueTree getCurrentServer() ;
  138. void setServerShouldAgree( bool should_agree) ;
  139. private:
  140. File configXmlFile ;
  141. ValueTree configValueTree ;
  142. Value dummyValue ;
  143. // validation
  144. void initialize() ;
  145. ValueTree sanitizeConfig( ValueTree default_config , ValueTree stored_config) ;
  146. void restoreVarTypeInfo(ValueTree store) ;
  147. void sanitizeUsers() ;
  148. void sanitizeChannels( ValueTree channels) ;
  149. void storeConfig() ;
  150. void establishSharedStore() ;
  151. bool sanityCheck() ;
  152. // helpers
  153. ValueTree getOrAddServer(String host_name , String login ,
  154. String pass , bool is_anonymous) ;
  155. String filteredName( String a_name) ;
  156. // event handlers
  157. void valueChanged( Value& a_value) override ;
  158. void valueTreePropertyChanged(ValueTree& a_node , const Identifier& key) override ;
  159. void valueTreeChildAdded( ValueTree& a_parent_node , ValueTree& a_node) override ;
  160. void valueTreeChildRemoved( ValueTree& a_parent_node , ValueTree& a_node) override ;
  161. // unused ValueTree::Listener interface methods
  162. // called when a tree's children have been re-shuffled.
  163. void valueTreeChildOrderChanged(ValueTree& a_parent_node) override {} ;
  164. // called when a tree has been added or removed from a parent node.
  165. void valueTreeParentChanged(ValueTree& a_node) override {} ;
  166. // called when a tree is made to point to a different internal shared object.
  167. void valueTreeRedirected(ValueTree& a_node) override {} ;
  168. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LinJamConfig) ;
  169. } ;
  170. #endif // _LINJAMCONFIG_H_