STAROS - Setvolume front-end de amixer
Rédigé par spheris
Aucun commentaire
Classé dans : accessoire, audio, starOS
Bonjour,
Je vous propose Setvolume, un logiciel de gestion de votre carte son pour le projet StarOS
.
Avec Setvolume, vous pouvez :
- Activer/Désactiver une voie sonore
- Augmenter ou diminuer le son de votre carte son.
- Mettre en silence un canal sonore.
Cette interface utilise amixer pour piloter la carte son.
Vos commentaires sont les bienvenues.
Comme pour toutes applications du projet StarOS, vous devez avoir le répertoire .star à la dans le répertoire /home/user/
Voici le code de l'application :
' Gambas class file ' This program is a part of the star desktop project ' it's a Front-end made in gambas of amixer command line program for Linux 'Free source, you can redistribute source free. ' January 2022 made by spheris 'For any help, remark, questions : www.gambaslinux.fr Private modif As Boolean 'if modif we write config file Private $pic As String 'image path Private $dev As New String[100] 'device number Private $name As New String[100] 'channel name Private $cap As New String[100] 'capabilities Private $limit As New String[100] 'max value of device Private $mode As New String[100] 'stereo or mono mode Private $left As New String[100] 'left current value of device Private $right As New String[100] 'right current value of device Private $act As New String[100] 'enabled device or not Private k As String[] 'separated textarea lines Private id As Integer 'current id when add data Private $ch As New Integer[8] 'channel order '******************************* INTERFACE VIEW ********************************** Public Sub _new() $pic = System.User.Home & "/star/config/img/" Rconfig() End Private Sub Rconfig() 'load configuration file Dim a As String Dim b As String[] Dim c As Integer a = File.Load(System.User.Home & "/.star/audio/order") a = Trim(a) Wait 0.2 b = Split(a, ";") For c = 0 To 5 $ch[c] = CInt(b[c]) Next End Public Sub Form_Open() Me.Center() Me.Icon = Picture[$pic & "setvolume.xpm"] Me.Text = "Sound control configurator / Mixer" cmd() Wait 0.2 Rfile() upview() End '******************************* EVENTS ****************************************** Public Sub bclose_Click() Dim a As String a = Str($ch[0]) & ";" & Str($ch[1]) & ";" & Str($ch[2]) & ";" & Str($ch[3]) & ";" & Str($ch[4]) & ";" & Str($ch[5]) & ";" If modif Then File.Save(System.User.Home & "/.star/audio/order", a) Endif Me.Close() End '******************************* CODE ********************************************* Private Sub cmd() 'extract amixer devices and parameter Exec ["amixer"] To TextArea1.Text End Private Sub Rfile() 'read Textarea to extract datas Dim v As Integer Dim l As Integer k = Split(TextArea1.Text, Chr(10)) 'separate all textarea lines For v = 0 To k.Count - 1 'read every line If Left(k[v], 3) = "Sim" Then Inc id Dname(k[v]) Endif If Left(k[v], 6) = " Capa" Then Dcap(k[v]) If Left(k[v], 6) = " Play" Then Dmode(k[v]) If Left(k[v], 6) = " Limi" Then Dmax(k[v]) If Left(k[v], 6) = " Mono" Then Dmono(k[v]) If Left(k[v], 9) = " Front L" Then Dstl(k[v]) If Left(k[v], 9) = " Front R" Then Dstr(k[v]) Next For l = 1 To id taudio.Add(l, $name[l], Picture[$pic & "speaker16.xpm"]) Next End Private Sub Dname($s As String) 'extract device name and card Dim a As String[] a = Split($s, "'") $name[id] = a[1] $dev[id] = Right(a[2], 1) End Private Sub Dcap($s As String) 'extract capabilities Dim a As String[] a = Split($s, ":") $cap[id] = a[1] End Private Sub Dmode($s As String) 'Extract stereo mode or mono Dim a As String[] a = Split($s, ":") $mode[id] = a[1] $mode[id] = Trim($mode[id]) End Private Sub Dmax($s As String) 'extract maximal device value Dim a As String[] a = Split($s, " ") $limit[id] = a.Last End Private Sub Dmono($s As String) ' 'extract current volume et activity on mono channel Dim a As String[] Dim b As String[] a = Split($s, ":") If Left($mode[id], "1") = "M" Then b = Split(a[1], " ") Select Case b.Count Case 3 $act[id] = b[2] Case 6 $left[id] = b[2] $right[id] = b[2] $act[id] = b[5] End Select Endif End Private Sub Dstl($s As String) 'extract current volume et activity on left channel Dim a As String[] a = Split($s, " ") Select Case a.Count Case 7 $left[id] = a[4] $right[id] = a[4] Case 8 $left[id] = a[5] $right[id] = a[5] Case 9 $left[id] = a[5] $right[id] = a[5] End Select End Private Sub Dstr($s As String) 'extract current volume et activity on right channel Dim a As String[] a = Split($s, " ") Select Case a.Count Case 7 $left[id] = a[4] $right[id] = a[4] Case 8 $left[id] = a[5] $right[id] = a[5] Case 9 $left[id] = a[5] $right[id] = a[5] End Select End Public Sub taudio_MouseDrag() If Mouse.Left Then If taudio.Current <> Null Then taudio.Drag(taudio.Current.Text) Drag.Icon = Picture[$pic & "speaker16.xpm"] Endif End Public Sub Mquit_Click() bclose_Click() End Public Sub ln1_Drop() modif = True $ch[0] = taudio.Current.Key upview() End Public Sub ln2_Drop() $ch[1] = taudio.Current.Key modif = True upview() End Public Sub ln3_Drop() $ch[2] = taudio.Current.Key modif = True upview() End Public Sub ln4_Drop() $ch[3] = taudio.Current.Key modif = True upview() End Public Sub ln5_Drop() $ch[4] = taudio.Current.Key modif = True upview() End Public Sub ln6_Drop() $ch[5] = taudio.Current.Key modif = True upview() End Public Sub sl1_MouseUp() Exec ["amixer", "sset", ln1.Text, sl1.Value] End Public Sub sl2_MouseUp() Exec ["amixer", "sset", ln2.Text, sl2.Value] End Public Sub sl3_MouseUp() Exec ["amixer", "sset", ln3.Text, sl3.Value] End Public Sub sl4_MouseUp() Exec ["amixer", "sset", ln4.Text, sl4.Value] End Public Sub sl5_MouseUp() Exec ["amixer", "sset", ln5.Text, sl5.Value] End Public Sub sl6_MouseUp() Exec ["amixer", "sset", ln6.Text, sl6.Value] End Public Sub Mabout_Click() Fabout.Show() End Private Sub upview() ln1.Text = $name[$ch[0]] sl1.MaxValue = CInt($limit[$ch[0]]) sl1.Value = $left[$ch[0]] Select Case $act[$ch[0]] Case "[off]" cen1.Value = False Case "[on]" cen1.Value = True End Select ln2.Text = $name[$ch[1]] sl2.MaxValue = CInt($limit[$ch[1]]) sl2.Value = $left[$ch[1]] Select Case $act[$ch[1]] Case "[off]" cen2.Value = False Case "[on]" cen2.Value = True End Select ln3.Text = $name[$ch[2]] sl3.MaxValue = CInt($limit[$ch[2]]) sl3.Value = $left[$ch[2]] Select Case $act[$ch[2]] Case "[off]" cen3.Value = False Case "[on]" cen3.Value = True End Select ln4.Text = $name[$ch[3]] sl4.MaxValue = CInt($limit[$ch[3]]) sl4.Value = $left[$ch[3]] Select Case $act[$ch[3]] Case "[off]" cen4.Value = False Case "[on]" cen4.Value = True End Select ln5.Text = $name[$ch[4]] sl5.MaxValue = CInt($limit[$ch[4]]) sl5.Value = $left[$ch[4]] Select Case $act[$ch[4]] Case "[off]" cen5.Value = False Case "[on]" cen5.Value = True End Select ln6.Text = $name[$ch[5]] sl6.MaxValue = CInt($limit[$ch[5]]) sl6.Value = $left[$ch[5]] Select Case $act[$ch[5]] Case "[off]" cen6.Value = False Case "[on]" cen6.Value = True End Select End