This started off as a simple tool so i could right click a .wav audio file and convert it to mp3 using LAME.
It uses the wav folder name as album and parent folder as artist or can be set manually.
you can also select different bitrate settings.
It seemed to work fine, i can select files from a filechooser and add manually in the gui or pass arguments (wav file paths) to it at launch.
but if i selected more than one file on the desktop and right clicked to "Open with Wav2mp3" then it wouldn't launch as one program with multiple arguments it would launch multiple instances of the program with one argument each.
So i needed a way to check if the program was already running and send the arguments to that one instead.
I found a way using a ServerSocket control so the 1st instance of the app sets up a listening socket and any subsequent apps that load use a simple shell command to tell the 1st app to add the files to its queue and exit.
I'm sure the app could use some more error handling/debugging/refining but could provide some insights for some for resolving a similar issue.
So i guess it's beta , i've only just made it so may be some quirks.
I plan to add more options (quality, priority, etc)
attachment contains source and app
(bugfixed 19:00 28 July 2020)
(non resizable version , see below for updated one)
Wav2mp3 (using serversocket for app to app control)
- BruceSteers
- Posts: 1578
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Wav2mp3 (using serversocket for app to app control)
Last edited by BruceSteers on Tuesday 28th July 2020 10:29pm, edited 3 times in total.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- cogier
- Site Admin
- Posts: 1127
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Wav2mp3 (using serversocket for app to app control)
I like the way you get the program to load 'Lame'. I thought the program could do with being a little more flexible regarding the size of the Form. So I messed with the Form and include the same code with an expanding Form. You can now move the central partition as well.
- BruceSteers
- Posts: 1578
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Wav2mp3 (using serversocket for app to app control)
Lol you beat me to it
only last night i was experimenting with the vsplit and hsplit containers and setting the Layout[] params
I also found a little bug
seems if only a single instance was loaded the server sockets wasn't being set to listen
I think it was here..
(19:00 20/July/20)
only last night i was experimenting with the vsplit and hsplit containers and setting the Layout[] params
I also found a little bug
seems if only a single instance was loaded the server sockets wasn't being set to listen
I think it was here..
Code: Select all
Else ' we are only instance so just add args to queue and start server socket
For c = 1 To a.Count - 1
ListBox1.Add(a[c])
Next
ServerSocket1.Listen()
Endif
Last edited by BruceSteers on Tuesday 28th July 2020 10:27pm, edited 2 times in total.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- cogier
- Site Admin
- Posts: 1127
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Wav2mp3 (using serversocket for app to app control)
Sorry but the expanding form has gone, it's even smaller than before and the program crashes at line 15 'Public mu As Music'
- BruceSteers
- Posts: 1578
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Wav2mp3 (using serversocket for app to app control)
aah sorry yeah i'd made some other changes like the terminal now has a separate form, is resizable and remembers it's pos/size.
was experimenting seing if any of the controls could convert the audio like the image controls can convert formats but to no success.
Seems i left the Music control deffinition in the declartations
I'll try to merge both our changes later. (sorry i'm new to "CO" production)
I'll upload the orig with the changes for now to the old posts.
was experimenting seing if any of the controls could convert the audio like the image controls can convert formats but to no success.
Seems i left the Music control deffinition in the declartations
I'll try to merge both our changes later. (sorry i'm new to "CO" production)
I'll upload the orig with the changes for now to the old posts.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- BruceSteers
- Posts: 1578
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Wav2mp3 (using serversocket for app to app control)
Ps, Sorry i didn't mention , i was experimenting with the resizing controls on a blank app not this one.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- BruceSteers
- Posts: 1578
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Wav2mp3 (using serversocket for app to app control)
I tried , for ages and couldn't quite figure out how to merge the changes my friend,
Sorry tried to get my head around how you were doing things but in the end i figured it'd be easier for me to do it the way i figured out last night. (i feel bad you wasted your time)
So it's resizeable now (thanks for the nudge) and on exit it will save it's window size, position and the fileview/queuelist split position.
Sorry tried to get my head around how you were doing things but in the end i figured it'd be easier for me to do it the way i figured out last night. (i feel bad you wasted your time)
So it's resizeable now (thanks for the nudge) and on exit it will save it's window size, position and the fileview/queuelist split position.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- BruceSteers
- Posts: 1578
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Wav2mp3 (using serversocket for app to app control)
Any views on how i've handled the multiple launching issue with the server socket?
Re. selecting multiple files from desktop and selecting "Open with wav2mp3" made multiple instances of the app load instead of one with multiple args.
I couldn't find any other way , i tried a pipe , but sending text to a pipe was only showing in the gambas IDE i couldn't get the app to react.
In searching for a solution i found on the gambas main development page Benoît Minisini saying to someone that gambas apps do not have a way (built in) to receive commands from another process directly and somebody else mentioned the use of sockets as a way around but hadn't tried.
so I tried
Anyone know of any other ways around this issue?
I might trim this app down to a bare bones "just add files to a list" so it just handles the multiple launches and could be handy code for someone else.
Re. selecting multiple files from desktop and selecting "Open with wav2mp3" made multiple instances of the app load instead of one with multiple args.
I couldn't find any other way , i tried a pipe , but sending text to a pipe was only showing in the gambas IDE i couldn't get the app to react.
In searching for a solution i found on the gambas main development page Benoît Minisini saying to someone that gambas apps do not have a way (built in) to receive commands from another process directly and somebody else mentioned the use of sockets as a way around but hadn't tried.
so I tried
Anyone know of any other ways around this issue?
I might trim this app down to a bare bones "just add files to a list" so it just handles the multiple launches and could be handy code for someone else.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- cogier
- Site Admin
- Posts: 1127
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Wav2mp3 (using serversocket for app to app control)
The program does what it says on the tin. It would be nice to be able to double-click the created file and hear the outcome.
You could have done this with a 'Task'. I put up an example of this on the Farm called TaskExample. This however only does one background task but you can look at the fun we had maxing out all 8 cores of a processor at once here.Anyone know of any other ways around this issue?
- BruceSteers
- Posts: 1578
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Wav2mp3 (using serversocket for app to app control)
Cool cheers I'll check that out.
I figured how to do the same thing with a pipe last night, itried that first but got stuck..
I was stuck getting a pipe command to not hang the program until the pipe gets some input.
Then i found a workaround setting a timer event to read the pipe but send it a signal first.
Ie.
Shell "echo \"\" >/tmp/fifo1"
Hfile= Pipe "/tmp/fifo1" for read
Etc.
Then the pipe wouldn't hang as it would read the echo and if another process has echoed the pipe it catches that text too so I trimmed the output and checked if It wasnt blank.
Serversocket I'd say was favourable in this case though as pipe uses physical drive.
The pipe code anyway for our fellow gambassers ......
the folder..
Gambas docs looks like i should be able to use the "Watch" arg with the Pipe command and trigger a File_Read() event but I couldn't figure out that one, I found all variables of the Pipe command to hang waiting for a message then let go.
So i just used the read option.
I figured how to do the same thing with a pipe last night, itried that first but got stuck..
I was stuck getting a pipe command to not hang the program until the pipe gets some input.
Then i found a workaround setting a timer event to read the pipe but send it a signal first.
Ie.
Shell "echo \"\" >/tmp/fifo1"
Hfile= Pipe "/tmp/fifo1" for read
Etc.
Then the pipe wouldn't hang as it would read the echo and if another process has echoed the pipe it catches that text too so I trimmed the output and checked if It wasnt blank.
Serversocket I'd say was favourable in this case though as pipe uses physical drive.
The pipe code anyway for our fellow gambassers ......
Code: Select all
' Gambas class file
Public hFile As File
Public Sub Timer1_Timer() ' timer is set to 2 second interval and enabled in form.
Dim LiveLine, MsgText As String
Shell "echo '' >/tmp/FIFO1"
hFile = Pipe "/tmp/FIFO1" For Read
Do
Read #hFile, LiveLine, -256
If Not LiveLine Then Break
MsgText = LiveLine
Loop
MsgText = Trim(MsgText)
Debug "MsgText='"; MsgText; "'"
' if the MsgText is not blank then something else has been sent to the pipe so this is where your
' program can react to the message.
If MsgText <> "" Then TextArea1.Text = "Recieved text from pipe /tmp/FIFO1\n'" & MsgText & "'"
End
Public Sub Form_Close()
Kill "/tmp/FIFO1"
Debug "Exitting..."
End
So i just used the read option.
If at first you don't succeed , try doing something differently.
BruceS
BruceS