*/}}
Przeglądaj źródła

Audio detached and lcd improvements

YimingWu 1 rok temu
rodzic
commit
a32ade2f96
6 zmienionych plików z 34 dodań i 22 usunięć
  1. 6 2
      la_audio.c
  2. 2 1
      la_interface.h
  3. 5 3
      la_kernel.c
  4. 1 1
      la_tns.h
  5. 12 10
      la_tns_kernel.c
  6. 8 5
      resources/la_properties.c

+ 6 - 2
la_audio.c

@@ -16,6 +16,7 @@
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#define MINIAUDIO_IMPLEMENTATION
 #include "miniaudio.h"
 
 #include "la_5.h"
@@ -366,7 +367,6 @@ void laInitMiniAudio(){
         printf("%d - %s\n", iDevice, pPlaybackInfos[iDevice].name);
     }
 
-
     ma_device_config config = ma_device_config_init(ma_device_type_playback);
     config.playback.pDeviceID= 0;
     config.playback.format   = ma_format_f32;
@@ -384,7 +384,7 @@ void laInitMiniAudio(){
     pthread_spin_init(&MAIN.Audio->AudioStatusLock,0);
 
 }
-void laDeinitMiniAudio(){
+void laDeinitAudio(){
     pthread_spin_destroy(&MAIN.Audio->AudioStatusLock);
     ma_device_stop(&MAIN.Audio->AudioDevice);
     ma_device_uninit(&MAIN.Audio->AudioDevice);
@@ -612,3 +612,7 @@ void laInitAudio(){
     laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_SYNTHESIZER, &LA_IDN_FM,&LA_IDN_VCA,&LA_IDN_NOISE,&LA_IDN_SCOPE,0);
     laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_SYSTEM_SOUND, &LA_IDN_OUTPUT,0);
 }
+
+void laAudioDummy(){
+    return 0;
+}

+ 2 - 1
la_interface.h

@@ -293,6 +293,7 @@ STRUCTURE(laInitArguments){
     int HasTextureInspector;
     int HasHistories;
     int HasTerminal;
+    int HasAudio;
 };
 
 NEED_STRUCTURE(laAnimation);
@@ -1749,7 +1750,7 @@ void la_AudioPreFrame();
 
 void laRebuildSynthGraphs();
 void laInitAudio();
-void laDeinitMiniAudio();
+void laDeinitAudio();
 
 #define LA_INPUT_CONTROLLER_NODE_MODE_BTN 0
 #define LA_INPUT_CONTROLLER_NODE_MODE_AXIS 1

+ 5 - 3
la_kernel.c

@@ -645,6 +645,7 @@ void laSetDefaultInitArguments(laInitArguments* ia){
     ia->HasTextureInspector=0;
     ia->HasHistories=0;
     ia->HasTerminal=1;
+    ia->HasAudio=0;
 }
 void laSetCompleteInitArguments(laInitArguments* ia){
     ia->GLMajor=3; ia->GLMinor=3; ia->BufferSamples=0;
@@ -654,6 +655,7 @@ void laSetCompleteInitArguments(laInitArguments* ia){
     ia->HasTextureInspector=1;
     ia->HasHistories=1;
     ia->HasTerminal=1;
+    ia->HasAudio=1;
 }
 void laProcessInitArguments(int argc, char* argv[],laInitArguments* ia) {
     MAIN.GLMajor=MAIN.GLMinor=-1;
@@ -915,7 +917,7 @@ int laGetReadyWith(laInitArguments* ia){
     la_RegisterAnimationResources();
     la_RegisterWindowKeys();
 
-    laInitAudio();
+    if(MAIN.InitArgs.HasAudio) laInitAudio();
 
     laFinalizeUiTemplates();
     laFinalizeOperators();
@@ -956,7 +958,7 @@ void laShutoff(int SavePrefereces){
 
     if(MAIN.Cleanup) MAIN.Cleanup();
 
-    laDeinitMiniAudio();
+    if(MAIN.InitArgs.HasAudio) laDeinitAudio();
 
     strSafeDestroy(&MAIN.WorkingDirectory);
     strSafeDestroy(&MAIN.example_string);
@@ -7183,7 +7185,7 @@ int laFinalize(){
 void la_PreFrame(){
     if(MAIN.PreFrame){ MAIN.PreFrame(); }
     la_AnimationPreFrame();
-    la_AudioPreFrame();
+    if(MAIN.InitArgs.HasAudio) la_AudioPreFrame();
 }
 void la_PostFrame(){
     for(laListItemPointer* lip=MAIN.DeferredRedrawList.pFirst;lip;lip=lip->pNext){

+ 1 - 1
la_tns.h

@@ -1223,7 +1223,7 @@ int tnsStringGetWidth(char *content, int Count, int UseMono);
 int tnsStringGetWidthU(uint32_t *contentU, int Count, int UseMono);
 void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
 int tnsDrawLCD7_ProgressSystem(real x, real y, real Percent);
-void tnsDrawStringLCD(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
+void tnsDrawStringLCD(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags, real Scale);
 void tnsDrawStringAutoM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
 void tnsDrawStringAuto(char *content, real Color[4], int L, int R, int T, int Flags);
 void tnsDrawStringWithPriority(char *Label, char *MajorContent, real Color[4], int TextAlign, int L, int R, int T, int Flags);

+ 12 - 10
la_tns_kernel.c

@@ -2899,8 +2899,8 @@ int tnsDrawLCD7_ProgressSystem(real x, real y, real Percent){
     return 1;
     return 0;
 }
-int tnsMakeLCD7(real x, real y, real w, real h, int ch){
-    int uc=ch; real shear=h/12;
+int tnsMakeLCD7(real x, real y, real w, real h, real shear, int ch){
+    int uc=ch;
     if(ch>='0' && ch<='9'){ uc-='0'; } 
     else {return 0;}
     for(int i=0;i<7;i++){
@@ -2913,8 +2913,8 @@ int tnsMakeLCD7(real x, real y, real w, real h, int ch){
     }
     return 1;
 }
-int tnsMakeLCD16(real x, real y, real w, real h, int ch){
-    int uc=ch; real shear=h/12;
+int tnsMakeLCD16(real x, real y, real w, real h, real shear, int ch){
+    int uc=ch;
     if(ch>='0' && ch<='9'){ uc-='0'; }
     elif(ch>='A' && ch<='Z'){ uc-='A'; uc+=10; }
     elif(ch>='a' && ch<='z'){ uc-='a'; uc+=(10+26); }
@@ -2929,12 +2929,14 @@ int tnsMakeLCD16(real x, real y, real w, real h, int ch){
     }
     return 1;
 }
-void tnsDrawStringLCD(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags){
+void tnsDrawStringLCD(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags, real Scale){
+    if(Scale<1e-5) return;
     real MA=FM->UsingFont->MonoAdvance;
     real sx = L; int sy = T; real dx=MA; real hgap=LA_RH/15; real vgap=LA_RH/5;
     int i,advance=1;
     int len = contentU?strlenU(contentU):strlen(content);
-    int RevY=(Flags&LA_TEXT_REVERT_Y);
+    int RevY=(Flags&LA_TEXT_REVERT_Y); int TH=LA_RH-vgap*2; real shear=TH/12;
+    if(RevY){ TH*=-1; vgap*=-1; } TH*=Scale;dx*=Scale;hgap*=Scale;vgap*=Scale;shear*=Scale;
     int OneLine=(Flags&LA_TEXT_ONE_LINE);
     int Use16=(Flags&LA_TEXT_LCD_16);
 
@@ -2952,20 +2954,20 @@ void tnsDrawStringLCD(char *content, uint32_t* contentU, real Color[4], int L, i
         }
         
         if(Use16){
-            if(tnsMakeLCD16(sx+hgap, sy+vgap, dx-hgap*2, LA_RH-vgap*2, UC)) any=1;
+            if(tnsMakeLCD16(sx+hgap, sy+vgap, dx-hgap*2, TH, shear, UC)) any=1;
         }else{
-            if(tnsMakeLCD7(sx+hgap, sy+vgap, dx-hgap*2, LA_RH-vgap*2, UC)) any=1;
+            if(tnsMakeLCD7(sx+hgap, sy+vgap, dx-hgap*2, TH, shear, UC)) any=1;
         }
 
         sx += dx;
         
         if(BreakNow){ break; }
     }
-    if(any){ tnsColor4dv(Color); tnsPackAs(GL_LINES); glLineWidth(dx/10); tnsFlush(); glLineWidth(1); }
+    if(any){ tnsColor4dv(Color); tnsPackAs(GL_LINES); }
 }
 void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags){
     if(Flags&(LA_TEXT_LCD_16|LA_TEXT_LCD_7)){
-        tnsDrawStringLCD(content,contentU,Color,L,R,T,Flags); return;
+        tnsDrawStringLCD(content,contentU,Color,L,R,T,Flags,1.0); return;
     }
     real sx = L; int sy = (LA_RH!=LA_RH0)?(((((real)FM->UsingFont->height/LA_RH0-0.5)/MAIN.UiScale)+0.5)*LA_RH + T):(FM->UsingFont->height+T);
     real MA=FM->UsingFont->MonoAdvance;

+ 8 - 5
resources/la_properties.c

@@ -1218,7 +1218,7 @@ void la_RegisterInternalProps(){
             laAddSubGroup(p, "input_mapping", "Input Mapping", "Input mapping page collection","la_input_mapping_collection",0,0,0,offsetof(LA,InputMapping),0,0,0,0,0,0,0,LA_UDF_SINGLE);
             
             laAddSubGroup(p, "animation", "Animation", "Animation data","la_animation",0,0,0,offsetof(LA,Animation),0,0,0,0,0,0,0,LA_UDF_SINGLE);
-            laAddSubGroup(p, "audio", "Audio", "Audio data","la_audio",0,0,0,offsetof(LA,Audio),0,0,0,0,0,0,0,LA_UDF_SINGLE);
+            if(MAIN.InitArgs.HasAudio) laAddSubGroup(p, "audio", "Audio", "Audio data","la_audio",0,0,0,offsetof(LA,Audio),0,0,0,0,0,0,0,LA_UDF_SINGLE);
 
             laAddStringProperty(p, "identifier", "Identifier", "Identifier", 0,0,0,0,0,0,0,laget_MainIdentifier, 0,0,LA_AS_IDENTIFIER|LA_READ_ONLY);
             laAddSubGroup(p, "test_ucn", "TEST UCN", "---", "udf_content_node",0,0,0,offsetof(LA, TEST_Link), 0,0,0,0,0,0,0,0);
@@ -1233,10 +1233,13 @@ void la_RegisterInternalProps(){
                 LA_WIDGET_STRING_PLAIN, 0,0,0,0,0,0,laget_UnknownPropertyString, 0,0,LA_READ_ONLY);
         
         }
-        p = laAddPropertyContainer("la_audio", "Audio", "Audio management", 0,0, sizeof(laAudio), 0,0,1);{
-            laAddSubGroup(p,"synths","Synthesizers","Synthesizers","la_synth",0,0,0,-1,0,0,0,0,0,0,offsetof(laAudio,Synths),0);
-            sp=laAddSubGroup(p, "current_synth", "Current Synthesizer", "Current synthesizer","la_synth",0,0,0,offsetof(laAudio,CurrentSynth),laget_FirstSynth,0,laget_ListNext,laset_CurrentSynth,0,0,0,LA_UDF_REFER);
-            laSubGroupDetachable(sp,laget_FirstSynth,laget_ListNext);
+        
+        if(MAIN.InitArgs.HasAudio){
+            p = laAddPropertyContainer("la_audio", "Audio", "Audio management", 0,0, sizeof(laAudio), 0,0,1);{
+                laAddSubGroup(p,"synths","Synthesizers","Synthesizers","la_synth",0,0,0,-1,0,0,0,0,0,0,offsetof(laAudio,Synths),0);
+                sp=laAddSubGroup(p, "current_synth", "Current Synthesizer", "Current synthesizer","la_synth",0,0,0,offsetof(laAudio,CurrentSynth),laget_FirstSynth,0,laget_ListNext,laset_CurrentSynth,0,0,0,LA_UDF_REFER);
+                laSubGroupDetachable(sp,laget_FirstSynth,laget_ListNext);
+            }
         }
 
         p = laAddPropertyContainer("la_node_category", "Node Category", "Node category", 0,laui_IdentifierOnly, sizeof(laNodeCategory), 0,0,1);{