Got an idea for enhancing PureBasic? New command(s) you'd like to see?
es_91
Enthusiast
Posts: 298 Joined: Thu Jan 27, 2011 12:00 pm
Location: DE
Post
by es_91 » Sat Sep 10, 2016 12:01 am
For wavPack an official dll package exists on their major web page
http://www.wavpack.com/ for download and usag of the .lib file distributed using, for example, the code postd by wilbert below:
wilbert wrote:
Code: Select all
EnumerationBinary
#OPEN_WVC
#OPEN_TAGS
#OPEN_WRAPPER
#OPEN_2CH_MAX
#OPEN_NORMALIZE
#OPEN_STREAMING
#OPEN_EDIT_TAGS
#OPEN_FILE_UTF8
EndEnumeration
ImportC "wavpackdll.lib"
WavpackCloseFile (*wpc)
WavpackGetBitsPerSample (*wpc)
WavpackGetBytesPerSample (*wpc)
WavpackGetNumChannels (*wpc)
WavpackGetNumSamples (*wpc)
WavpackGetReducedChannels (*wpc)
WavpackGetSampleRate (*wpc)
WavpackOpenFileInput (infilename.p-ascii, *error, flags, norm_offset)
WavpackSeekSample (*wpc, sample)
WavpackUnpackSamples (*wpc, *buffer, samples)
EndImport
*error = AllocateMemory(81)
*wpc = WavpackOpenFileInput("32bit_float.wv", *error, 0, 0)
If *wpc = 0
Debug PeekS(*error, -1, #PB_Ascii)
Else
numChannels = WavpackGetNumChannels(*wpc)
bitsPerSample = WavpackGetBitsPerSample(*wpc)
bytesPerSample = WavpackGetBytesPerSample(*wpc)
sampleRate = WavpackGetSampleRate(*wpc)
numSamples = WavpackGetNumSamples(*wpc)
Debug "Channels : " + Str(numChannels)
Debug "Bits per sample : " + Str(bitsPerSample)
Debug "Bytes per sample : " + Str(bytesPerSample)
Debug "Sample rate : " + Str(sampleRate)
Debug ""
Debug "Number of samples : " + Str(numSamples)
BufferSize = 4 * numSamples * numChannels
*Buffer = AllocateMemory(BufferSize)
If *Buffer And WavpackUnpackSamples(*wpc, *Buffer, numSamples) = numSamples
Debug "Decoded"
Else
Debug "Decode error"
EndIf
WavpackCloseFile(*wpc)
EndIf
PS: don't forget it requires "32bit_float.wv" maybe you want to put some openFileRequester () there.
Last edited by
es_91 on Sun Sep 11, 2016 7:33 am, edited 2 times in total.
Keya
Addict
Posts: 1890 Joined: Thu Jun 04, 2015 7:10 am
Post
by Keya » Sat Sep 10, 2016 12:39 am
es_91 wrote: Soon, i believe, the last mp3 patents in US are running out ... maybe one day Fred and Timo will provide MP3 decoder plugins within PureBasic?
i could be mistaken but i'm pretty sure you only need a license from Fraunhoffer or whatever if you want to write a (commercial)
ENCODER for mp3 - everyone is free to write their own
decoder , including commercial - again, if i'm not mistaken. I think the LAME codec is able to get away with encoding because it's free. But don't quote me on any of this!
es_91
Enthusiast
Posts: 298 Joined: Thu Jan 27, 2011 12:00 pm
Location: DE
Post
by es_91 » Sat Sep 10, 2016 1:01 am
Keya wrote: But don't quote me on any of this!
I won't.
[edited]
The basic MP3 decoding and encoding technology is patent-free in the European Union, all patents having expired there. In the United States, the technology will be substantially patent-free on 31 December 2017 (see below).
en. wikipedia. org /wiki /MP3 #Licensing, ownership and legislation
Last edited by
es_91 on Sat Sep 10, 2016 1:11 am, edited 1 time in total.
Keya
Addict
Posts: 1890 Joined: Thu Jun 04, 2015 7:10 am
Post
by Keya » Sat Sep 10, 2016 1:09 am
Stages in becoming a programmer:
1) Become a lawyer
2) Learn programming
3) Get sued by a troll over some ridiculous software patent
Congratulations, YOU'VE MADE IT!
es_91
Enthusiast
Posts: 298 Joined: Thu Jan 27, 2011 12:00 pm
Location: DE
Post
by es_91 » Sat Sep 10, 2016 3:58 am
guess you gotta do IT with a little protection these days ...
Last edited by
es_91 on Sat Sep 10, 2016 9:27 am, edited 2 times in total.
wilbert
PureBasic Expert
Posts: 3942 Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands
Post
by wilbert » Sat Sep 10, 2016 5:28 am
Windows (x64)
Raspberry Pi OS (Arm64)
es_91
Enthusiast
Posts: 298 Joined: Thu Jan 27, 2011 12:00 pm
Location: DE
Post
by es_91 » Sat Sep 10, 2016 6:54 am
[...] Sorry, no experience, no skills.
But I'll give it a try if that's what you meant. ..which you surely did. ^^
Last edited by
es_91 on Sun Sep 11, 2016 7:34 am, edited 1 time in total.
wilbert
PureBasic Expert
Posts: 3942 Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands
Post
by wilbert » Sat Sep 10, 2016 7:17 am
es_91 wrote: But I'll give it a try if that's what you meant. ..which you surely did. ^^
The zip file contains a pre-build dll and lib for Windows both x86 and x64.
http://www.wavpack.com/wavpackdll.zip
Code: Select all
EnumerationBinary
#OPEN_WVC
#OPEN_TAGS
#OPEN_WRAPPER
#OPEN_2CH_MAX
#OPEN_NORMALIZE
#OPEN_STREAMING
#OPEN_EDIT_TAGS
#OPEN_FILE_UTF8
EndEnumeration
EnumerationBinary
#MODE_WVC
#MODE_LOSSLESS
#MODE_HYBRID
#MODE_FLOAT
#MODE_VALID_TAG
#MODE_HIGH
#MODE_FAST
#MODE_EXTRA
#MODE_APETAG
#MODE_SFX
#MODE_VERY_HIGH
#MODE_MD5
#MODE_XMODE = $7000
#MODE_DNS = $8000
EndEnumeration
ImportC "wavpackdll.lib"
WavpackCloseFile (*wpc)
WavpackGetBitsPerSample (*wpc)
WavpackGetBytesPerSample (*wpc)
WavpackGetMode (*wpc)
WavpackGetNumChannels (*wpc)
WavpackGetNumSamples (*wpc)
WavpackGetReducedChannels (*wpc)
WavpackGetSampleRate (*wpc)
WavpackOpenFileInput (infilename.p-ascii, *error, flags, norm_offset)
WavpackSeekSample (*wpc, sample)
WavpackUnpackSamples (*wpc, *buffer, samples)
EndImport
*error = AllocateMemory(81)
*wpc = WavpackOpenFileInput("32bit_float.wv", *error, 0, 0)
If *wpc = 0
Debug PeekS(*error, -1, #PB_Ascii)
Else
numChannels = WavpackGetNumChannels(*wpc)
bitsPerSample = WavpackGetBitsPerSample(*wpc)
bytesPerSample = WavpackGetBytesPerSample(*wpc)
sampleRate = WavpackGetSampleRate(*wpc)
numSamples = WavpackGetNumSamples(*wpc)
Debug "Channels : " + Str(numChannels)
Debug "Bits per sample : " + Str(bitsPerSample)
Debug "Bytes per sample : " + Str(bytesPerSample)
Debug "Sample rate : " + Str(sampleRate)
Debug ""
Debug "Number of samples : " + Str(numSamples)
BufferSize = 4 * numSamples * numChannels
*Buffer = AllocateMemory(BufferSize)
If *Buffer And WavpackUnpackSamples(*wpc, *Buffer, numSamples) = numSamples
Debug "Decoded"
Else
Debug "Decode error"
EndIf
WavpackCloseFile(*wpc)
EndIf
Last edited by
wilbert on Sun Sep 11, 2016 3:02 pm, edited 6 times in total.
Windows (x64)
Raspberry Pi OS (Arm64)
es_91
Enthusiast
Posts: 298 Joined: Thu Jan 27, 2011 12:00 pm
Location: DE
Post
by es_91 » Sat Sep 10, 2016 7:43 am
My bad. Thank you. Much appreciated!
Last edited by
es_91 on Sun Sep 11, 2016 7:35 am, edited 1 time in total.
wilbert
PureBasic Expert
Posts: 3942 Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands
Post
by wilbert » Sat Sep 10, 2016 8:00 am
es_91 wrote: Nice to have wavPack.
It seems like you have to convert the samples yourself to the sample format you wish.
Windows (x64)
Raspberry Pi OS (Arm64)
es_91
Enthusiast
Posts: 298 Joined: Thu Jan 27, 2011 12:00 pm
Location: DE
Post
by es_91 » Sat Sep 10, 2016 9:22 am
Yes. That is something wavPack does not want to do. Equal to this: wavPack will not convert CD-resoluted material too far below 200 kbit/s. That again, for quality purposes. With lower resoluting material, rates below 50 kbit/s are possible.
If you wish to not just compress or reduce data, but also to resample it, wavPack probably won't offer a build-in solution.
And honestly, i think that is the right choice.