Skip to content

Commit

Permalink
update v1.5 24/11/2023
Browse files Browse the repository at this point in the history
- corrected freefile variable type to long
  integer causes issues when opening multiple
  file in succession
- trimmed utilfile.bas
- reworked shuffleplay...again... should now
  work as intended; only play a item in the set once
  untill the set is exhausted.
- tweaked drc, volume was stil choppy with certain
  music is now more in line with, xmplay's auto amp
  dynamic gain, as such more smoother.
- added dutch (nl) as locale
- tidy up conf.ini
- added .wbfe (winfbe) project file
  • Loading branch information
thrive4 committed Nov 24, 2023
1 parent c0e5f93 commit 90873a3
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 347 deletions.
8 changes: 4 additions & 4 deletions app.rc
Expand Up @@ -10,8 +10,8 @@ FB_PROGRAM_ICON ICON "f:\dev\freebasic\projects\audioplayer-sdlmixer\app.ico"

// add version and file info in exe windows only
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 4, 0, 000
PRODUCTVERSION 1, 4, 0, 0
FILEVERSION 1, 5, 0, 000
PRODUCTVERSION 1, 5, 0, 0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x9L
Expand All @@ -29,13 +29,13 @@ BEGIN
VALUE "Comments", "needs sdl2 and sdl2 mixer libs"
VALUE "CompanyName", ""
VALUE "FileDescription", "audioplayer with sdl2 mixer"
VALUE "FileVersion", "1, 4, 0, 000"
VALUE "FileVersion", "1, 5, 0, 000"
VALUE "InternalName", ""
VALUE "LegalCopyright", ""
VALUE "OriginalFilename", "audioplayer"
VALUE "PrivateBuild", ""
VALUE "ProductName", "audioplayer"
VALUE "ProductVersion", "1, 4, 0, 0"
VALUE "ProductVersion", "1, 5, 0, 0"
END
END
BLOCK "VarFileInfo"
Expand Down
12 changes: 8 additions & 4 deletions audioplayer.bas
Expand Up @@ -49,7 +49,7 @@ dim itm as string
dim inikey as string
dim inival as string
dim inifile as string = exepath + "\conf\conf.ini"
dim f as integer
dim f as long
if FileExists(inifile) = false then
logentry("error", inifile + " file does not excist")
else
Expand Down Expand Up @@ -89,6 +89,7 @@ select case command(1)
' cleanup listplay files
delfile(exepath + "\" + "music" + ".tmp")
delfile(exepath + "\" + "music" + ".lst")
delfile(exepath + "\" + "music" + ".swp")
logentry("terminate", "normal termination " + appname)
end select

Expand Down Expand Up @@ -231,7 +232,7 @@ end if

' listduration for recursive scan dir
if maxitems > 1 and instr(command(1), ".m3u") = 0 and instr(command(1), ".pls") = 0 then
dim tmp as integer
dim tmp as long
dim cnt as integer = 1
' count items in list
itemlist = exepath + "\music.tmp"
Expand Down Expand Up @@ -343,6 +344,7 @@ dim refreshinfo as boolean = true
dim taginfo(1 to 5) as string
dim firstmp3 as integer = 1
dim musiclevel as single
dim maxlevel as single
dim sleeplength as integer = 1000

readuilabel(exepath + "\conf\" + locale + "\menu.ini")
Expand All @@ -358,7 +360,8 @@ Do
' ghetto attempt of dynamic range compression audio
if drc = "true" then
' bass method
'drcvolume = 2.0f - max(loWORD(musiclevel), HIWORD(musiclevel)) / 32768
'maxlevel = min(loWORD(musiclevel), HIWORD(musiclevel)) / 32768.0f
'drcvolume = ((1.0f + (4.75f - maxlevel)) - maxlevel) * sourcevolume
drcvolume = 128
Mix_VolumeMusic(drcvolume)
else
Expand Down Expand Up @@ -499,7 +502,7 @@ Do
getuilabelvalue("year" , taginfo(4))
getuilabelvalue("genre" , taginfo(5))
Print
if taginfo(1) <> "----" and taginfo(2) <> "----" and instr(filename, ".mp3") <> 0 then
if taginfo(1) <> "----" and taginfo(2) <> "----" then
getuilabelvalue("current", currentsong & ". " & taginfo(1) + " - " + taginfo(2))
else
getuilabelvalue("current", currentsong & ". " & mid(left(filename, len(filename) - instr(filename, "\") -1), InStrRev(filename, "\") + 1, len(filename)))
Expand All @@ -524,6 +527,7 @@ cleanup:
' cleanup listplay files
delfile(exepath + "\" + "music" + ".tmp")
delfile(exepath + "\" + "music" + ".lst")
delfile(exepath + "\" + "music" + ".swp")
delfile(exepath + "\thumb.jpg")
delfile(exepath + "\thumb.png")

Expand Down
21 changes: 18 additions & 3 deletions audioplayer.nfo
@@ -1,10 +1,25 @@
update v1.4 (todo implement reworked log)
update v1.5 24/11/2023
- corrected freefile variable type to long
integer causes issues when opening multiple
file in succession
- trimmed utilfile.bas
- reworked shuffleplay...again... should now
work as intended; only play a item in the set once
untill the set is exhausted.
- tweaked drc, volume was stil choppy with certain
music is now more in line with, xmplay's auto amp
dynamic gain, as such more smoother.
- added dutch (nl) as locale
- tidy up conf.ini
- added .wbfe (winfbe) project file

update v1.4 28/10/2023
- fixed log creation (missing message)
- fixed appname made truncation .exe optional
- fixed checkpath did not set correct path after
function exit when path is correct
- fixed list when initating with a specific track or song
- reduced probabilty of same track playing in shuffle mode
- fixed list when initiating with a specific track or song
- reduced probability of same track playing in shuffle mode
- display current track / song number
- misc fixes to getmp3cover

Expand Down
Binary file added audioplayer.wfbe
Binary file not shown.
15 changes: 7 additions & 8 deletions readme.md
Expand Up @@ -3,21 +3,20 @@ basic audioplayer written in freebasic and bass\
supported audio types are .flac, .mp3, .m4a, .mp4, .ogg, .wav\
supported playlists .m3u, .pls\
ascii interface\
\
basic config options in conf.ini\
locale = <en, de, fr>\
defaultvolume = <1 .. 128>\
playtype = <shuffle, linear>\
' dynamic range compression *currently not working with sdl\
drc = <true, false>\
\
if present coverart will be extracted and written to file as thumb.jpg\
When a file or path is specified the current dir and sub dir(s)\
will be scanned for audio file(s) which will generate an internal playlist
## usage
audioplayer.exe "path to file or folder"\
if a file or path is specified the folder will be scanned for an audio file\
if the folder has subfolder(s) these will be scanned for audio files as well.
## configuration
basic config options in conf.ini\
locale = <en, de, fr, nl>\
defaultvolume = <1 .. 128>\
playtype = <shuffle, linear>\
' dynamic range compression *currently not working with sdl\
drc = <true, false>
## requirements
sdl2.dll (32bit)\
https://www.libsdl.org/
Expand Down
90 changes: 42 additions & 48 deletions shuffleplay.bas
Expand Up @@ -3,14 +3,19 @@ function createlist(folder as string, filterext as string, listname as string) a
' setup filelist
dim chk as boolean
redim path(1 to 1) As string
dim as integer i = 1, n = 1, f, attrib
dim as integer i = 1, n = 1, attrib
dim as long f, g
dim file as string
dim fileext as string
dim maxfiles as integer
f = freefile
dim filelist as string = exepath + "\" + listname + ".tmp"
open filelist for output as #f

g = freefile
dim filelistb as string = exepath + "\" + listname + ".lst"
open filelistb for output as #g

#ifdef __FB_LINUX__
const pathchar = "/"
#else
Expand Down Expand Up @@ -44,6 +49,7 @@ function createlist(folder as string, filterext as string, listname as string) a
fileext = lcase(mid(file, instrrev(file, ".")))
if instr(1, filterext, fileext) > 0 and len(fileext) > 3 then
print #f, path(i) & file
print #g, path(i) & file
maxfiles += 1
else
logentry("warning", "file format not supported - " + path(i) & file)
Expand All @@ -54,23 +60,20 @@ function createlist(folder as string, filterext as string, listname as string) a
i += 1
wend
close(f)
close(g)

' chk if filelist is created
if FileExists(filelist) = false then
logentry("warning", "could not create filelist: " + filelist)
end if

' setup base shuffle and reduce probability
dim lastitem as string = exepath + "\" + listname + ".lst"
chk = newfile(lastitem)

return maxfiles
end function

' used for listplay sets selected item as current
function setcurrentlistitem(listname as string, filename as string) as integer
dim listitem as string
dim tmp as integer
dim tmp as long
dim itemnr as integer = 1

' scan for filename in list
Expand All @@ -95,15 +98,16 @@ dim shared currentvideo as integer
function listplay (playtype as string, listname as string) as string

' setup item file and item count
dim tmp as integer
dim chk as boolean
Dim listitem as string
Dim currentitem as integer
dim itemnr as integer = 1
dim maxitems as integer = 0
dim baseitem as integer
dim lastitem as string = exepath + "\" + listname + ".lst"
dim listfile as string = exepath + "\" + listname + ".lst"
dim tempfile as string = exepath + "\" + listname + ".tmp"
dim swapfile as string = exepath + "\" + listname + ".swp"
dim as long tmp, swp

' work around for multiple lists todo improve
select case listname
Expand All @@ -118,6 +122,13 @@ function listplay (playtype as string, listname as string) as string
case "shader"
currentitem = currentshader
end select

' reset tempfile if empty
if FileLen(tempfile) = 0 then
FileCopy listfile, tempfile
logentry("notice", "item list reset!")
end if

' count items in list
tmp = readfromfile(tempfile)
Do Until EOF(tmp)
Expand All @@ -129,52 +140,30 @@ function listplay (playtype as string, listname as string) as string
' note linefeed at end of list caused by pipelinig on os
maxitems = itemnr - 1
itemnr = 1

' count items in list lastitem wipe when equal to maxitems
tmp = readfromfile(lastitem)
Do Until EOF(tmp)
Line Input #tmp, listitem
itemnr += 1
Loop
close(tmp)
if itemnr > maxitems then
If Kill(lastitem) <> 0 Then
logentry("error", "deleteing " + lastitem)
end if
chk = newfile(lastitem)
logentry("notice", "item list reset!")
end if
itemnr = 1
select case playtype
case "shuffle"
' choose an item
randomize
baseitem = int(rnd * maxitems) + 1
' fill lastitem list and check if item is already used
tmp = readfromfile(lastitem)
Do Until EOF(tmp)
Line Input #tmp, listitem
' check if already chosen reduce probabilty clunky but works....
if val(listitem) = baseitem then
' roll the dice and hope for the best
randomize
baseitem = int(rnd * maxitems) + 1
'print "old item #1" & listitem & " new choice " & baseitem
end if
if val(listitem) = baseitem then
' roll the dice and hope for the best
randomize
baseitem = int(rnd * maxitems) + 1
'print "old item #2" & listitem & " new choice " & baseitem
end if
loop
close(tmp)
chk = appendfile(lastitem, str(baseitem))
swp = 20
open swapfile for output as swp
tmp = readfromfile(tempfile)
Do Until EOF(tmp)
Line Input #tmp, listitem
if baseitem <> itemnr then
print #20, listitem
else
' nop
end if
itemnr += 1
Loop
close(tmp)
close (swp)
case "linear"
baseitem = 1
currentitem = currentitem + 1
baseitem = currentitem
' wrap to first image
' wrap to first item
if currentitem > maxitems then
baseitem = 1
end if
Expand All @@ -184,7 +173,7 @@ function listplay (playtype as string, listname as string) as string
currentitem = currentitem - 1
baseitem = currentitem
end if
' wrap to last image
' wrap to last item
if currentitem = 0 then
currentitem = maxitems
baseitem = currentitem
Expand All @@ -193,15 +182,20 @@ function listplay (playtype as string, listname as string) as string

' get specific item from list
tmp = readfromfile(tempfile)
dim dummy as string
itemnr = 1
Do Until EOF(tmp)
Line Input #tmp, listitem
if itemnr = baseitem then
currentitem = itemnr
exit do
dummy = listitem
end if
itemnr += 1
Loop
close(tmp)
if playtype = "shuffle" then
FileCopy swapfile, tempfile
end if

' work around for multiple lists todo improve
select case listname
Expand All @@ -217,6 +211,6 @@ function listplay (playtype as string, listname as string) as string
currentshader = currentitem
end select

return listitem
return dummy

end function

0 comments on commit 90873a3

Please sign in to comment.