La radio de Micoute

Programmation d'applications complexes
Avatar de l’utilisateur
Micoute
Messages : 2522
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

La radio de Micoute

Message par Micoute »

Salut à tous, pour faire comme tout le monde, j'ai aussi fait ma radio, je me suis inspiré de tous vos codes et ça donne ça :

Code : Tout sélectionner

EnableExplicit

IncludeFile "fmodex.pbi"
IncludeFile "MeterGadget.pbi"

Enumeration
  #Mainform
EndEnumeration

Enumeration Gadget
  #Option_0
  #Option_1
  #Option_2
  #Option_3
  #Option_4
  #Option_5
  #Option_6
  #Option_7
  #Option_8
  #Option_9
  #Option_10
  #Option_11
  #Option_12
  #Option_13
  #Option_14
  #Option_15
  #Conteneur
  #Volume
  #VU
  #Txt_Titre
  #txt_Volume
EndEnumeration

Enumeration Police
  #Police
EndEnumeration  

Define.l Event, GEvent, TiEvent

Global WindowStyle.i=#PB_Window_SystemMenu|#PB_Window_ScreenCentered
Global.i VuMeter, Police

Global fmodsystem.i, Channel.i, Sound.i
Global Dim Arr.F(512), N.i ; Tableau pour les 512 niveaux
Global Dim Station.s(15, 1)
Global Url.s
Global Dim VuMetre.MeterType(15)

Police = LoadFont(#Police, "Digit", 20, #PB_Font_Bold)

Procedure Reglages()
  FMOD_System_Create(@fmodsystem)
  FMOD_System_Init(fmodsystem, 32, 0, 0)
  
  FMOD_System_CreateStream(fmodsystem, @Url, #FMOD_CREATESTREAM, 0, @sound)
  FMOD_System_PlaySound(fmodsystem, 0, sound, 0, @channel) ; joue l'url
  
  FMOD_Channel_SetVolume(Channel, GetGadgetState(#Volume)/250)
  FMOD_Channel_GetSpectrum(channel, Arr(), 512, 0, 0 ) ; recuperere les 512 niveaux des frequences
EndProcedure

Procedure VUMeterUpdate()
  Protected Sum.f
  
  FMOD_Channel_GetSpectrum(channel, Arr(), 512, 0, 0 ) ; recuperere les 512 niveaux des frequences
  FMOD_System_Update(Channel)
  For N=0 To 512 
    Sum + Arr(N)
  Next
  SetMeterState(VuMeter, Sum*GetGadgetState(#Volume)/2)
EndProcedure

Procedure Stop()  
  FMOD_Channel_Stop(Channel)
      FMOD_System_Release(fmodsystem)
EndProcedure

Procedure Open_MainForm()
  OpenWindow(#Mainform, 0, 0, 500, 350, "La radio de Micoute", WindowStyle)
  SetWindowColor(#Mainform, $300000)
  VuMeter = MeterGadget(#PB_Any, 180, 70, 300, "VU")
  TextGadget(#Txt_Titre, 180, 20, 300, 30, Station(8,0), #PB_Text_Center)
  TrackBarGadget(#Volume, 180, 280, 300, 20, 0, 100)
  TextGadget(#txt_Volume, 180, 310, 300, 25, "20", #PB_Text_Center)
  ContainerGadget(#Conteneur, 10, 10, 150, 330, #PB_Container_Raised)
  For i = 0 To 15
    OptionGadget(i, 15, (i*19) + 10, 110, 19,Station(i, 0))
  Next
  SetGadgetColor(#Conteneur, #PB_Gadget_BackColor, $300000)
  SetGadgetColor(#Txt_Titre, #PB_Gadget_BackColor, $300000)
  SetGadgetColor(#Txt_Titre, #PB_Gadget_FrontColor, $00FFFF)
  SetGadgetFont(#Txt_Titre, Police)
  SetGadgetColor(#txt_Volume, #PB_Gadget_BackColor, $300000)
  SetGadgetColor(#txt_Volume, #PB_Gadget_FrontColor, $00FFFF)
  SetGadgetFont(#txt_Volume, Police)
  AddWindowTimer(#Mainform, 100, 100) 
  SetGadgetState(#Option_7, 1)
  SetGadgetState(#Volume, 20)
EndProcedure

Procedure Initialisation()
  Restore Stations
  For i = 0 To 15
    Read.s, Station(i, 0)
    Read.s, Station(i, 1)
  Next  
  ;Url ="http://50.7.98.106:8719"
  Url = Station(8,1)
  Open_MainForm()
EndProcedure

Initialisation()
Reglages()

Repeat
  Event   = WaitWindowEvent(100)    
  GEvent  = EventGadget()
  TiEvent = EventTimer()

  Select Event
    Case #PB_Event_Timer
      Select TIEvent
        Case 100
          VUMeterUpdate() 
      EndSelect
      
    Case #PB_Event_Gadget
      Select GEvent
        Case #Option_0 To #Option_15
          Stop()
          SetGadgetText(#Txt_Titre, UCase(Station(GEvent,0)))
          Url = Station(GEvent,1)
          Reglages()
          VUMeterUpdate()
        Case  #Volume
          Volume.f = GetGadgetState(#Volume) /250
          FMOD_Channel_SetVolume(Channel, Volume)
          SetGadgetText(#txt_Volume, Str(GetGadgetState(#Volume)))
      EndSelect
      
    Case #PB_Event_CloseWindow
      Stop()
      End
  EndSelect
ForEver

DataSection
  Stations:
  Data.s "Brume", "http://live140.impek.com:9974/"
  Data.s "Chante France","http://stream.chantefrance.com/stream_chante_france.mp3"
  Data.s "Chérie FM", "http://mp3.live.tv-radio.com/cherrie_fm/all/che_124310.mp3"
  Data.s "Chérie FM Frenchy","http://live.tv-radio.com/cherie_fm_frenchy/all/che_123008.mp3"
  Data.s "Couleur 3","http://broadcast.infomaniak.ch/rsr-couleur-high.mp3"
  Data.s "Demoiselle FM","http://213.186.61.62:8800/"
  Data.s "France Culture","http://mp3.live.tv-radio.com/franceculture/all/franceculturehautdebit.mp3"
  Data.s "France Info","http;//mp3.live.tv-radio.com/franceinfo/all/franceinfo.mp3"
  Data.s "France Inter","http://mp3.live.tv-radio.com/franceinter/all/franceinterhautdebit.mp3"
  Data.s "Le Mouv'","http://mp3.live.tv-radio.com/lemouv/all/lemouvhautdebit.mp3"
  Data.s "Nostalgie","http://mp3.live.tv-radio.com/nostalgie/all/nos_113812.mp3"
  Data.s "NRJ All French","http://mp3.live.tv-radio.com/nrj_friendly/all/nrj_164207.mp3"
  Data.s "Oxyradio","http://www.oxyradio.net:8000/hd.ogg"
  Data.s "Rires et chansons","http://95.81.147.3/rire_et_chansons/all/rir_124629.mp3"
  Data.s "RTL2","http://streaming.radio.rtl2.fr/rtl2-1-44-128"
  Data.s "RMC","http://vipicecast.yacast.net/rmc"
  Data.s "999","999"
EndDataSection
Si ça peut vous inspirer, ne vous gênez surtout pas !
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Avatar de l’utilisateur
Ar-S
Messages : 9472
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: La radio de Micoute

Message par Ar-S »

Si tu fournis du code faisant appel à des fichiers externes, il serait bon de les distribuer aussi ;)
"MeterGadget.pbi" et "fmodex.pbi"
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Avatar de l’utilisateur
Micoute
Messages : 2522
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

Re: La radio de Micoute

Message par Micoute »

Avec toutes mes excuses, voici le fichier MeterGadget.pbi de BasicallyPure, pour les autres fichiers, je ne sais pas comment on peut envoyer des fichiers par internet !

Code : Tout sélectionner

; Name:    MeterGadget.pbi
; Version: 1.2
; Author:  BasicallyPure
; Date:    3.29.2013
; OS:      Windows, Linux, Mac
; PB ver.: 5.11
; License: Free
;
; Syntaxe: résultat = MeterGadget( # Gadget , x , y, taille , [Titre ], [ Options])
; # Gadget | numéro pour identifier le gadget. # PB_Any peut être utilisé pour générer automatiquement .
; X , y | emplacement du gadget mètres.
; Taille | largeur de mètres, la hauteur est automatiquement calculée comme la taille / 1,5 .
; Titre | le texte à afficher sur la face du compteur .
;
; Drapeaux | les drapeaux peuvent être combinés en utilisant | ( opérateur Or ) .
; | # MTR_STYLE_VU , crée un mètre de style VU , par défaut style linéaire .
; | # MTR_STYLE_LED , ajoute une LED à un compteur indicateur de crête .
; | L'aiguille par défaut est dessinée sans lignes lissées .
; | En utilisant les indicateurs de style suivantes d'aiguille va augmenter l'utilisation du processeur .
; | # MTR_NEEDLE_VAR1 , dessiner l'aiguille avec une ligne épaisse anti-aliasing unique.
; | # MTR_NEEDLE_VAR2 , dessiner l'aiguille décrit avec des lignes anti-aliasing .
; | # MTR_NEEDLE_VAR3 , dessiner l'aiguille remplie de plusieurs appels anti-aliasing .
;
; Utiliser SetMeterState (# Gadget, poste ) pour régler position de l'aiguille .
; La plage de position est de 0 à 100 . Les valeurs hors de cette gamme sont écrêtées .
;
; GetMeterState (# Gadget) renvoie la position de l'aiguille.
;
; SetMeterSmoothing (# Gadget , valeur ) applique une fonction smooting au mouvement de l'aiguille.
; et les valeurs de lissage valides sont 0 , 2, 4, 8, 16, 32, 64, 128 .
;
; Si vous voulez changer les options de compteurs par défaut qui utilisent ces procédures.
; Les procédures devraient être appelés à comparaître devant le compteur est créé.
;
; setMeterGradientColor(C1, C2, C3, C4) | omettre tous les paramètres pour réinitialiser les couleurs par défaut.
; SetMeterCaptionFont(NumPolice)         | omettre paramètre pour revenir à la police par défaut.
; SetMeterScaleFont(NumPolice)            | omettre paramètre pour revenir à la police par défaut.
; SetMeterCaptionColor(couleur)            | omettre paramètre pour revenir à la couleur par défaut.
; SetMeterScaleColor(couleur)               | omettre paramètre pour revenir à la couleur par défaut.
; SetMeterNeedleColor(couleur)             | omettre paramètre pour revenir à la couleur par défaut.
; SetMeterBottomColor(couleur)            | omettre paramètre pour revenir à la couleur par défaut.

;
; Syntax: result = MeterGadget(#gadget, x, y, size, [caption], [flags])
;   #Gadget  | number to identify the gadget. #PB_Any can be used to auto-generate.
;   x, y     | location of the meter gadget.
;   size     | width of meter, height is automatically calculated as size / 1.5.
;   caption  | the text to display on the meter face.
;
;   flags  | flags may be combined by using | (bitwise OR operator).
;            | #MTR_STYLE_VU, creates a VU style meter, default is linear style.
;            | #MTR_STYLE_LED, adds a peak indicator LED to any meter.
;            | the default needle is drawn without anti-aliased lines.
;            | using the following needle style flags will increase CPU usage.
;            | #MTR_NEEDLE_VAR1, draw needle with a single anti-aliased thick line.
;            | #MTR_NEEDLE_VAR2, draw outlined needle with anti-aliased lines.
;            | #MTR_NEEDLE_VAR3, draw filled needle with multiple anti-aliased calls.
;
; use SetMeterState(#gadget, position) to set needle position.
; position range is from 0 to 100.  Values outside this range are clipped.
;
; GetMeterState(#gadget) returns the needle position.
;
; SetMeterSmoothing(#gadget, value) applies a smooting function to the needle movement.
;        valid smoothing values are 0, 2, 4, 8, 16, 32, 64, 128.
;
; if you want to change the default meter options use these procedures.
; the procedures should be called before the meter is created.
;
; setMeterGradientColor(C1, C2, C3, C4) | omit all parameters to reset default colors.
; SetMeterCaptionFont(fontNumber)       | omit parameter to return to default font.
; SetMeterScaleFont(fontNumber)          | omit parameter to return to default font.
; SetMeterCaptionColor(color)               | omit parameter to return to default color.
; SetMeterScaleColor(color)                  | omit parameter to return to default color.
; SetMeterNeedleColor(color)               | omit parameter to return to default color.
; SetMeterBottomColor(color)               | omit parameter to return to default color.

EnableExplicit

Structure MeterType
  width.i        ; meter width
  height.i       ; meter height
  flags.i        ; option flags, #MTR_STYLE_vu | #MTR_STYLE_LED
  position.f     ; needle position, returned with GetMeterState(GadNum)
  captionFont.i  ; use this font for meter caption
  captionColor.i ; caption text color
  scaleFont.i    ; use this font for scale labels
  scaleColor.i   ; color used for drawing scale and scale labels
  caption.s      ; meter caption
  gradColor_1.i  ; first color for gradient
  gradColor_2.i  ; second color for gradient
  gradColor_3.i  ; third color for gradient
  gradColor_4.i  ; forth color for gradient
  needleColor.i  ; color used to draw needle
  bottomColor.i  ; color of bottom region of meter face
  clip.i         ; indicates input exceeded maximum value (100)
  LED_radius.i   ; radius of LED
  LED_X.i        ; x location of peak LED indicator
  LED_Y.i        ; y location of peak LED indicator
  smoothing.i    ; smoothing value ( power of 2 up to 128 )
  buffer.f[128]  ; smoothing buffer
  bufferIdx.a    ; smoothing buffer index
  bufferSum.f    ; running sum of smoothing buffer
  mid_X.i        ; middle of meter (x axis)
  arcRadius.i    ; sets position of scale arc
  backImage.i    ; meter background image
  bottomImage.i  ; decorative bar at bottom of meter
EndStructure

Structure DefaultType
  gradientC_1.i
  gradientC_2.i
  gradientC_3.i
  gradientC_4.i
  captionFont.i
  captionColor.i
  scaleFont.i
  scaleColor.i
  needleColor.i
  bottomColor.i
EndStructure

;#MTR_STYLE_STD   = %0000
#MTR_STYLE_VU    = %0001
#MTR_STYLE_LED   = %0010
#MTR_NEEDLE_STD  = %0000
#MTR_NEEDLE_VAR1 = %0100
#MTR_NEEDLE_VAR2 = %1000
#MTR_NEEDLE_VAR3 = %1100

Define MtrDefaults.DefaultType
MtrDefaults\gradientC_1  = $60FFFF ;$00FFFF
MtrDefaults\gradientC_2  = $80DFDF ;$00FF00
MtrDefaults\gradientC_3  = $A0BFBF ;$00FF80
MtrDefaults\gradientC_4  = $FFAFAF ;$0000FF
MtrDefaults\captionColor = 0
MtrDefaults\captionFont  = LoadFont(#PB_Any,"Arial", 10, #PB_Font_Bold)
MtrDefaults\scaleFont    = LoadFont(#PB_Any,"Arial", 8)
MtrDefaults\scaleColor   = $FF0000
MtrDefaults\needleColor  = $0000FF
MtrDefaults\bottomColor  = $603030

Define mtr_default_caption_font = MtrDefaults\captionFont
Define mtr_default_Scale_font   = MtrDefaults\scaleFont

Dim Meter.MeterType(1)

NewMap MeterIndex.i() ; a Map to index Meter() with gadget number

Declare Draw_Meter(meterNumber)
Declare SetMeterState(meterNumber.i, position.f)
Declare g2D_AA_BlendColor(Color1.i, Color2.i, Blend.d)
Declare g2D_LineXY(x.i, y.i, x3.i, y3.i, Color.i=0, Thickness.i=1)

ProcedureDLL  MeterGadget(gadNum.i, x.i, y.i, size.i, caption.s = "", flags.i = 0)
  
  Shared Meter() ; structured array
  Shared MeterIndex() ; Map
  Shared MtrDefaults ; structure
  Static meterCount = 1
  Protected result.i, w.i, h.i
  
  If flags < 0 Or flags > %1111 : ProcedureReturn 0 : EndIf
  If size < 150 : size = 150 : EndIf
  w = size : h = w / 1.5
  
  result = CanvasGadget(gadNum, x, y, w, h, #PB_Canvas_Border)
  If result <> 0
    If gadNum = #PB_Any : gadNum = result : EndIf
    If meterCount > 1 : ReDim Meter(meterCount) : EndIf
    
    With Meter(meterCount)
      \width        = w - 4 ; adjusted for 4 pixel border of canvas gadget
      \height       = h - 4 ; adjusted for 4 pixel border of canvas gadget
      \flags        = flags
      \gradColor_1  = MtrDefaults\gradientC_1
      \gradColor_2  = MtrDefaults\gradientC_2
      \gradColor_3  = MtrDefaults\gradientC_3
      \gradColor_4  = MtrDefaults\gradientC_4
      \captionColor = MtrDefaults\captionColor
      \captionFont  = MtrDefaults\captionFont
      \scaleFont    = MtrDefaults\scaleFont
      \scaleColor   = MtrDefaults\scaleColor
      \needleColor  = MtrDefaults\needleColor
      \bottomColor  = MtrDefaults\bottomColor
      \smoothing    = 0
      \bufferIdx    = 0
      \bufferSum    = 0
      \LED_radius   = \width / 40
      \LED_X        = \width - 13 - 3*\LED_radius
      \LED_Y        = \height - \height * 0.35 - 2*\LED_radius
      \caption      = caption
      \mid_X        = \width / 2
      \arcRadius    = h * (w / (w + 50.0)) ; this locates the scale arc
      \backImage    = CreateImage(#PB_Any, \width, \height, 32)
      \bottomImage  = CreateImage(#PB_Any, \width, \height * 0.2, 32)
      
      MeterIndex(Str(gadNum)) = meterCount
      
      Draw_Meter(meterCount)
      
      StartDrawing(CanvasOutput(gadNum))
      DrawImage(ImageID(\backImage),0 ,0)
      StopDrawing()
      
    EndWith
    
    SetMeterState(gadNum, 0)
    
    MeterCount + 1
  EndIf
  
  ProcedureReturn result
EndProcedure

ProcedureDLL  Draw_Meter(meterNumber)
  Shared Meter()
  Protected x.i, y.i, px.i, py.i, angle.f, inc.f
  Protected vu.i, sf.f, color.i
  
  With Meter(meterNumber)
    
    StartDrawing(ImageOutput(\bottomImage))
    DrawingMode(#PB_2DDrawing_AlphaChannel)
    Box(0, 0, OutputWidth(), OutputHeight(), $00000000)
    DrawingMode(#PB_2DDrawing_AlphaBlend)
    RoundBox(0, 0, \width, \height * 0.3, \width / 20, \width / 20, $B0000000 + \bottomColor)
    StopDrawing()
    
    StartDrawing(ImageOutput(\backImage))
    DrawingMode(#PB_2DDrawing_Gradient)
    BackColor(\gradColor_4)
    GradientColor(0.33, \gradColor_3)
    GradientColor(0.66, \gradColor_2)
    FrontColor(\gradColor_1)
    LinearGradient(0, \height, 0, 0)
    Box(0, 0 ,\width, \height)
    DrawingMode(#PB_2DDrawing_Transparent)
    DrawingFont(FontID(\scaleFont))
    
    Circle(\mid_X, \height, \width * 0.1, 0)
    Circle(\mid_X, \height - 10, 4, \needleColor ! 1)
    
    inc = 1000 / \width
    angle = -45.0 - inc
    Repeat ; draw scale arc
      angle + inc
      If angle > 45.0 : angle = 45.0 : EndIf
      x = \mid_X  + Sin(Radian(angle)) * \arcRadius
      y = \height - Cos(Radian(angle)) * \arcRadius
      If angle <> -45.0
        LineXY(px,py,x,y,\scaleColor)
      EndIf
      px = x : py = y
    Until angle = 45
    
    If \flags & #MTR_STYLE_VU
      sf = 100 / Pow(10, 3/20)
      vu = 3
      Repeat
        angle = 0.9 * sf * Pow(10, vu/20) - 45
        px = \mid_X  + Sin(Radian(angle)) * (\arcRadius - 5)
        py = \height - Cos(Radian(angle)) * (\arcRadius - 5)
        x  = \mid_X  + Sin(Radian(angle)) * (\arcRadius + 5)
        y  = \height - Cos(Radian(angle)) * (\arcRadius + 5)
        LineXY(px, py, x, y, \scaleColor)
        
        Select vu
          Case -20, -10, -5, -3, -2, -1, 0, 1, 2, 3
            If vu < 0 : color = 0 : Else : color = $0000FF : EndIf
            x  = \mid_X  + Sin(Radian(angle-1)) * (\arcRadius + 22)
            y  = \height - Cos(Radian(angle-1)) * (\arcRadius + 22)
            DrawRotatedText(x, y, Str(Abs(vu)), -angle, color)
        EndSelect
        
        Select vu
          Case -2 To 3 : vu - 1
          Case -3 : vu - 2
          Case -5 : vu - 5
          Case -30 To -10 : vu - 10
        EndSelect
        
      Until vu < -30
      
      DrawingFont(FontID(\captionFont))
      DrawText(10, \height * 0.4, "_", 0)
      DrawText(\width - 15, \height * 0.4 + 5, "+", $0000FF)
      
    Else ; linear style
      angle = -45.0 : inc = 9
      Repeat ; draw scale tic marks
        px = \mid_X  + Sin(Radian(angle)) * (\arcRadius - 5)
        py = \height - Cos(Radian(angle)) * (\arcRadius - 5)
        x  = \mid_X  + Sin(Radian(angle)) * (\arcRadius + 5)
        y  = \height - Cos(Radian(angle)) * (\arcRadius + 5)
        LineXY(px, py, x, y, \scaleColor)
        
        DrawingFont(FontID(\scaleFont))
        x  = \mid_X  + Sin(Radian(angle-1)) * (\arcRadius + 20)
        y  = \height - Cos(Radian(angle-1)) * (\arcRadius + 20)
        DrawRotatedText(x, y, Str(angle/9 + 5), -angle, \captionColor)
        
        angle + inc
      Until angle > 45
    EndIf
    
    If \flags & #MTR_STYLE_LED
      Circle(\LED_X, \LED_Y, \LED_radius + 2, 0)
      Circle(\LED_X, \LED_Y, \LED_radius , $404080)
      DrawingFont(FontID(\scaleFont))
      DrawText(\width - 27 - 3*\LED_radius, \height - \height * 0.35, "PEAK", \captionColor)
    EndIf
    
    If \caption
      DrawingFont(FontID(\captionFont))
      FrontColor(\captionColor)
      x = (\Width  - TextWidth(\caption)) / 2
      y = (\Height - TextHeight(\caption))/ 2
      DrawText(x, y, \caption)
    EndIf
    StopDrawing()
  EndWith
  
EndProcedure

ProcedureDLL  SetMeterState(GadNum.i, position.f)
  ; appeler cette procédure pour régler la position de l'aiguille. 
  ; la gamme de mesure est de 0 à 100. 
  ; les valeurs en dehors de cette gamme sont écrêtées.
  
  ; call this procedure to adjust the needle position.
  ; range of position is from 0 to 100.
  ; values outside this range are clipped.
  
  Shared Meter(), MeterIndex()
  Protected meterNumber.i = MeterIndex(Str(GadNum))
  Protected mask.a, nw.i, x.i, y.i
  
  If meterNumber = 0
    ProcedureReturn 0 ; Meter number is not valid
  EndIf
  
  If position < 0 : position = 0 : EndIf
  
  With Meter(meterNumber)
    If position >= 100 : \clip = 8 : position = 100 : EndIf
    \position = position
    
    If \smoothing
      mask = \smoothing - 1
      \bufferSum - \buffer[\bufferIdx & mask]
      \buffer[\bufferIdx & mask] = position
      \bufferSum + position
      \bufferIdx + 1
      position = \bufferSum / \smoothing ; this is the running average
    EndIf
    
    position = Radian(0.9 * position - 45)
    x = \mid_X  + Sin(position) * (\arcRadius)
    y = \height - Cos(position) * (\arcRadius)
    
    StartDrawing(CanvasOutput(GadNum))
    
    ; first draw the meter background
    DrawImage(ImageID(\backImage),0 ,0)
    
    ; draw the needle
    Select \flags & %1100
      Case #MTR_NEEDLE_STD
        nw.i = 2 + Round(1.35 - Cos(position), #PB_Round_Nearest)
        Circle(x, y, 2, \needleColor)
        LineXY(\mid_X - 4, \height - 10, x-nw, y, \needleColor)
        LineXY(\mid_X + 4, \height - 10, x+nw, y, \needleColor)
        LineXY(\mid_X - 4, \height - 10, \mid_X + 4, \height - 10, \needleColor)
        FillArea(\mid_X, \height - 11, \needleColor, \needleColor ! 1)
      Case #MTR_NEEDLE_VAR1 ; draw needle with a single anti-aliased thick line.
        Circle(x, y, 2, \needleColor)
        g2d_LineXY(\mid_X, \height - 10, x, y, \needleColor, 5)
      Case #MTR_NEEDLE_VAR2 ; draw outlined needle with anti-aliased lines.
        nw.i = 2 + Round(1.35 - Cos(position), #PB_Round_Nearest)
        Circle(x, y, 2, \needleColor)
        g2d_LineXY(\mid_X - 4, \height - 10, x-nw, y, \needleColor)
        g2d_LineXY(\mid_X + 4, \height - 10, x+nw, y, \needleColor)
      Case #MTR_NEEDLE_VAR3 ; draw filled needle with multiple anti-aliased calls.
        nw.i = 2 + Round(1.35 - Cos(position), #PB_Round_Nearest)
        Circle(x, y, 2, \needleColor)
        LineXY(\mid_X - 4, \height - 10, x-nw, y, \needleColor)
        LineXY(\mid_X + 4, \height - 10, x+nw, y, \needleColor)
        LineXY(\mid_X - 4, \height - 10, \mid_X + 4, \height - 10, \needleColor)
        ; Call FillArea() before color edges are blurred with g2d_LineXY()
        FillArea(\mid_X, \height - 11, \needleColor, \needleColor ! 1)
        g2d_LineXY(\mid_X - 4, \height - 10, x-nw, y, \needleColor)
        g2d_LineXY(\mid_X + 4, \height - 10, x+nw, y, \needleColor)
    EndSelect
    
    If \flags & #MTR_STYLE_LED
      If \clip : \clip - 1
        Circle(\LED_X, \LED_Y, \LED_radius, $0000FF)
      EndIf
    EndIf
    
    ; draw the bottom region using an alpha blended image
    DrawAlphaImage(ImageID(\bottomImage),0, \height - ImageHeight(\bottomImage))
    
    StopDrawing()
  EndWith
  
EndProcedure

ProcedureDLL  GetMeterState(GadNum.i)
  Shared Meter(), MeterIndex()
  Protected meterNumber = MeterIndex(Str(GadNum))
  
  If meterNumber = 0
    ProcedureReturn 0 ; Meter number is not valid
  EndIf
  
  ProcedureReturn Meter(meterNumber)\position
EndProcedure

ProcedureDLL  SetMeterSmoothing(GadNum.i, value.i)
  ; les valeurs de lissage valides sont 0, 2, 4, 8, 16, 32, 64, 128
  ; d'autres valeurs auront une gamme limitée et convertis à une puissance de 2
  
  ; valid smoothing values are 0, 2, 4, 8, 16, 32, 64, 128
  ; other values will be range limited and converted to a power of 2
  
  Shared Meter(), MeterIndex()
  Protected n.i, meterNumber = MeterIndex(Str(GadNum))
  
  If meterNumber = 0
    ProcedureReturn 0 ; Meter number is not valid
  EndIf
  
  If value > 128 : value = 128
  ElseIf value < 2 : value = 0
  Else : value = Pow(2, Round(Log(value) / Log(2),#PB_Round_Nearest))
  EndIf
  
  With Meter(meterNumber)
    
    For n = 0 To value - 1
      \buffer[n] = \position
    Next n
    
    \bufferIdx = 0
    \bufferSum = \position * value
    \smoothing = value
  EndWith
  
EndProcedure

ProcedureDLL  SetMeterCaptionFont(font.i = -1)
  Shared MtrDefaults, mtr_default_caption_font
  If font = -1
    font = mtr_default_caption_font
  EndIf
  
  If IsFont(font)
    MtrDefaults\captionFont = font
  EndIf
EndProcedure

ProcedureDLL  SetMeterCaptionColor(color.i = 0)
  Shared MtrDefaults
  MtrDefaults\captionColor = color
EndProcedure

ProcedureDLL  SetMeterScaleFont(font.i = -1)
  Shared MtrDefaults, mtr_default_Scale_font
  If font = -1
    font = mtr_default_Scale_font
  EndIf
  
  If IsFont(font)
    MtrDefaults\scaleFont = font
  EndIf
EndProcedure

ProcedureDLL  SetMeterScaleColor(color.i = $FF0000)
  Shared MtrDefaults
  MtrDefaults\scaleColor = color
EndProcedure

ProcedureDLL  SetMeterNeedleColor(color.i = $0000FF)
  Shared MtrDefaults
  MtrDefaults\needleColor = color
EndProcedure

ProcedureDLL  SetMeterBottomColor(color.i = $603030)
  Shared MtrDefaults
  MtrDefaults\bottomColor = color
EndProcedure

Procedure SetMeterGradientColor(top.i = $60FFFF, mid1.i = $80DFDF, mid2.i = $A0BFBF, bottom.i = $FFAFAF)
  Shared MtrDefaults
  MtrDefaults\gradientC_1 = top
  MtrDefaults\gradientC_2 = mid1
  MtrDefaults\gradientC_3 = mid2
  MtrDefaults\gradientC_4 = bottom
EndProcedure

ProcedureDLL .i g2D_AA_BlendColor(Color1.i, Color2.i, Blend.d)
  ; RASHAD, lisse les bords de couleur pour produire près de l'anti-aliasing
  
  ; RASHAD, smooths color edges to produce near anti-aliasing
  Protected Red, Green, Blue, Red2, Green2, Blue2
  Red = Color1 & $FF
  Green = Color1 >> 8 & $FF
  Blue = Color1 >> 16
  Red2 = Color2 & $FF
  Green2 = Color2 >> 8 & $FF
  Blue2 = Color2 >> 16
  Red = Red * Blend + Red2 * (1-Blend)
  Green = Green * Blend + Green2 * (1-Blend)
  Blue = Blue * Blend + Blue2 * (1-Blend)
  ProcedureReturn (Red | Green << 8 | Blue << 16)
EndProcedure

ProcedureDLL  g2D_LineXY(x.i, y.i, x3.i, y3.i, Color.i=0, Thickness.i=1)
  ; RASHAD, Le Soldat Inconnu et les autres
  
  ; RASHAD, Le Soldat Inconnu and others
  Protected.i Wd = x3 - X
  Protected.i Ht = y3 - Y
  Protected.i SignX, SignY, n, nn, Color_Found
  Protected.d Thick, x2, y2, Application, Hypo, CosPhi, SinPhi
  If Wd >= 0
    SignX = 1
  Else
    SignX = -1
    Wd = - Wd
  EndIf
  If Ht >= 0
    SignY = 1
  Else
    SignY = -1
    Ht = -Ht
  EndIf
  Thick = Thickness / 2
  Hypo = Sqr(Wd * Wd + Ht * Ht)
  CosPhi = Wd / Hypo
  SinPhi = -Sin(ACos(CosPhi))
  For n = -Thickness To Wd + Thickness
    For nn = -Thickness To Ht + Thickness
      x2 = n * CosPhi - nn * SinPhi
      y2 = Abs(n * SinPhi + nn * CosPhi)
      If y2 <= (Thick + 0.5)
        Application =  0.5 + Thick - y2
        If Application > 1
          Application = 1
        EndIf
        If (x2 > -1) And (x2 < (Hypo + 1))
          If x2 < 0
            Application * (1 + x2)
          ElseIf x2 > Hypo
            Application * (1 - x2 + Hypo)
          EndIf
        Else
          Application = 0
        EndIf
        If Application > 0
          If Application < 1
            Color_Found = Point(X + n * SignX, Y + nn * SignY)
            Plot(X + n * SignX, Y + nn * SignY, g2D_AA_BlendColor(Color, Color_Found, Application))
          Else
            Plot(X + n * SignX, Y + nn * SignY, Color)
          EndIf
        EndIf
      EndIf
    Next nn
  Next n
EndProcedure

DisableExplicit
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: La radio de Micoute

Message par falsam »

:arrow: Télécharger Fmod Ex(install).zip
Cette archive contient fmodex.dll, fmodex.pbi, le fichier d'aide fmodex.chm (Anglais)

:arrow: Télécharger fmodex help.zip
Si le fichier d'aide contenu dans le fichier précédent ne fonctionne pas, télécharger celui-ci.
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
Micoute
Messages : 2522
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

Re: La radio de Micoute

Message par Micoute »

Merci falsam, j'adore qu'un forum fonctionne comme ça !
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Répondre