Still, you should only return -1 when you try to read and the file is at the end. Basically, that check should happen before reading. Going to investigate more about the rest.
EDIT: Using C file functions works fine so I can only assume there's something wrong with the filesystem on GMod. Looking deeper into it.
EDIT2: You should've added debug messages right in the start of the callbacks.
[code]Open: something.mp3
Open (ID: 97471840)
StreamLenProc
Size: 10713268 B
StreamReadProc
Read read_len: 4096
Read length: 4096
Read Tell: 4096
Read EndOfFile: 0
StreamSeekProc
Seek Offset: 10713125
Seek Tell: 10713125
StreamReadProc
Read read_len: 143
Read length: 4096
Read Tell: 10713268
Read EndOfFile: 1
StreamSeekProc
StreamSeekProc
StreamSeekProc
StreamSeekProc
StreamSeekProc
StreamSeekProc
StreamSeekProc
StreamSeekProc
StreamSeekProc
StreamLenProc
StreamSeekProc
StreamLenProc
StreamSeekProc
StreamLenProc
StreamLenProc
StreamSeekProc
StreamLenProc
StreamSeekProc
StreamLenProc
StreamSeekProc
StreamLenProc
StreamSeekProc
StreamLenProc
StreamSeekProc
StreamLenProc
StreamCloseProc
Close End (ID: 97471840)[/code]
See those StreamLenProc and StreamSeekProc without no other messages?
EDIT3: Remove your g_FileSystem->IsOk(fh) checks. They seem to return false when the file has the end of file flag activated. Also, from what I've seen in your code, there seems to be lots of memory leaks. Be careful with that stuff. Get rid of the memory the first moment it stops being needed. Also, that file handle, you don't need to create a new one. In bass_streamfile2 line 560. Just do FileHandle_t fh = g_FileSystem->Open(file, "rb", "GAME"); and fh is valid in the callbacks.
[QUOTE=Grocel;39549281]I have tried to implement your suggestions, but I wasn't very successfully. :tinfoil:
I have fallowed the given examples and, I think, I have placed the file functions the right places. But bass' [URL="http://www.un4seen.com/doc/#bass/BASS_StreamCreateFileUser.html"]BASS_StreamCreateFileUser()[/URL] doesn't seem to work properly for me. It reads the first kilobytes of a file, jump to the end and then returns error 41 ("File format not supported"). The given file itself is valid.
I have seen that there is a connection between the return value of [URL="http://www.un4seen.com/doc/#bass/FILELENPROC.html"]FILELENPROC[/URL] and the position [URL="http://www.un4seen.com/doc/#bass/FILESEEKPROC.html"]FILESEEKPROC[/URL] function seeks to: Bass seems to seek to the file size, which results hitting the file end. If I change the return of FILESEEKPROC to a smaller number (like 4096) the playback works a bit.
But it only plays mp3s even Bass should support much more. The playback seems broken to. It start some were in the middle sometimes.
StreamCreate is not an alternative because it only support samples, it can't play mp3s and stuff.
If someone wants to help me, please take a look at the code I have uploaded here: [url]https://dl.dropbox.com/u/16654098/gmod/Bass/gm_bass2.zip[/url]
The problem area is between line 417 and 620.
Use [I]"channel, err = BASS.StreamFile2(string file [, bool Play3D, bool PlayLoop])"[/I] for testing in-game. While trying to play the given file, it will print some stuff to the console. So you will see what gm_bass and Bass is trying to do.[/QUOTE]
Why aren't you using streamproc
Thank you guys, [URL="http://svn.xp-dev.com/svn/2d3d_Browser/bin/modules"]here is your update[/URL]:
[CODE] - channel:Stop() will no longer free the channel.
- Added channel:Remove()
- Added channel:IsValid(), you can use IsValid(channel) too.
- Added channel:IsPaused()
- Added channel:IsStalled()
- Renamed:
- channel:play() -> channel:Play()
- channel:stop() -> channel:Stop()
- channel:pause() -> channel:Pause()
- channel:getplaying() -> channel:IsPlaying()
- This enables some syntax highlighting.
- Playing files (BASS.StreamFile()) streamed properly and uses GMod's file system now. (Supports playing of addon contents)[/CODE]
I also done some clean up in the code. Please feel free reporting bugs or memory leaks. [URL="http://svn.xp-dev.com/svn/2d3d_Browser/gm_bass_documentation.txt"]
Documentation[/URL] is updated too. Enjoy.
@danielga: You just have found the solution, it's working fine now.
@Map in a box: I think you can't, because it's linked to StreamCreate.
[QUOTE=Grocel;39549281]StreamCreate is not an alternative because it only support samples, it can't play mp3s and stuff.[/QUOTE]
Never mind, it's done anyway.
Edit: I just noticed some crash bugs. I fixed them.
Just make aliases, don't rename.
[CODE] - Updated bass.dll to 2.4.10.
- Added, renamed and cleaned up a lot of stuff. (Documentation soon.)
- Fixing filesystem being broken after update.
- It will no longer stop the module from loading if it breaks again.[/CODE]
Don't worry there are aliases for every renamed function. But they can be removed every time, so please adapt your code when you see renamed stuff in the change log as soon as possible.
[del]I will remake the documentation soon. I didn't have the time for it yet.[/del]
[URL="https://dl.dropbox.com/u/16654098/gmod/Bass/gm_bass_documentation.html"]The new documentation is there[/URL].
fuck this, I LOVE YOU. THis is the most awesome DLL I've seen in a while! Congratz bro REALLY! =)
Hope more coders can check this incredible work!
I cant seem to set the time more than once? im using an online mp3
[CODE]
self.iChange = self.iChange + 1;
local iChange = self.iChange;
local iStation = self.iStation;
local function fCallback(channel, err)
print(channel, err)
if(err != 0) then
return;
end
if(iChange != self.iChange) then
channel:Remove();
return;
end
if(self.rChannel != nil) then
self.rChannel:Remove();
self.rChannel = nil;
end
self.rChannel = channel;
local iServerTime = RealTime();
local iLength = self.rChannel:GetLength();
local iStartPos = iServerTime - (math.floor(iServerTime / iLength) * iLength);
iStartPos = math.Round(iStartPos);
//local iStartPos = iServerTime % iLength;
self.rChannel:SetTime(iStartPos);//Stations[iStation]["time"]);
Msg("StartPos: " .. iStartPos .. "\n\n");
self.rChannel:Pause();
self.rChannel:Stop();
Stations[iStation]["time"] = iStartPos;
self.rChannel:SetTime(iStartPos)
self.rChannel:Play();
self.rChannel:SetTime(iStartPos)
Msg(self.rChannel:GetTime())
end
BASS.StreamFileURL(Stations[self.iStation]["stream"], fCallback, false);
[/CODE]
Any ideas? when i set the time it only seems to set the time once and its incorrect
[QUOTE]
BASSChannel: [id:2952790026][file:[URL]http://127.0.0.1/radio/wave.mp3][/URL][online:true][loop:false][3d:true] 0
StartPos: 854
GetTimePos: 16.117551803589
[/QUOTE]
[QUOTE=recox998;40052313]I cant seem to set the time more than once? im using an online mp3
[CODE]
//code
[/CODE]
Any ideas? when i set the time it only seems to set the time once and its incorrect[/QUOTE]
As we discussed in PM it's not possible to set the TimePos of online streams. That's because they are handled as endless as you find on radio broadcasts.
I just fixed gm_bass2 being broken after the Steampipe update.
Is there any way to close all streams on the client? Having an issue with phantom streams (streams getting stuck on the client's system)
[QUOTE=KarmaLord;41022064]Is there any way to close all streams on the client? Having an issue with phantom streams (streams getting stuck on the client's system)[/QUOTE]
At the moment the module is pretty broken (again).
Garry added BASS to GMod. It's binding is a bit messy and unfinished at the moment, that causes conflicts.
[QUOTE=Grocel;41031000]At the moment the module is pretty broken (again).
Garry added BASS to GMod. It's binding is a bit messy and unfinished at the moment, that causes conflicts.[/QUOTE]
Did he really? Thought he never would lol. But yeah, realized it was broken like an hour after I posted that. Still, is there a way once it gets fixed? Or just a way to dump all streams so they can be reset?
[QUOTE=KarmaLord;41032158]Did he really? Thought he never would lol. But yeah, realized it was broken like an hour after I posted that. Still, is there a way once it gets fixed? Or just a way to dump all streams so they can be reset?[/QUOTE]
Yes there is, but not for me. You have to wait.
Any update on Garry's implementation? I've been keeping up with the updates, but just wondering if gm_bass still conflicts.
Just did an update, it's working again just fine:
[CODE]- Fixed gm_bass2 conflicts with GMod's BASS.
- It uses GMod's BASS now.
- Removed all obsolete functions.
- Removed BASS.GetListenerPos() and BASS.SetListenerPos(), they aren't needed anymore.
- Added number BASS.ModuleVersion, it's the version of gm_bass2.[/CODE]
[QUOTE=Grocel;41330533]Just did an update, it's working again just fine:
[CODE]- Fixed gm_bass2 conflicts with GMod's BASS.
- It uses GMod's BASS now.
- Removed all obsolete functions.
- Removed BASS.GetListenerPos() and BASS.SetListenerPos(), they aren't needed anymore.
- Added number BASS.ModuleVersion, it's the version of gm_bass2.[/CODE][/QUOTE]
I keep getting "[ERROR] BASS Init failed, error code 23." in the server console when I require("bass2"). Do I still need to put the required modules next to the hl2.exe?
Error 23 means "Illegal device!". So there is no sound device (sound card), I guess.
[QUOTE=Grocel;41424054]Error 23 means "Illegal device!". So there is no sound device (sound card), I guess.[/QUOTE]
Oh, our dedicated server doesn't have a sound card, oh well. :suicide:
For some reason i always get error 20 (illegal parameter) when i try to play mp3 from dropbox.
Error 20 Channel nil Decode error code An illegal parameter was specified!
My quick test code:
[lua]
require'bass2'
if BASS then
local url='dl.dropboxusercontent.com/u/3766002/01-invaders-must-die.mp3'
print('URL',url)
if myStream and IsValid(myStream) then myStream:Stop() myStream:Remove() end
local function callback(stream,error) print('Error',error,'Channel',stream,'Decode error code',BASS.DecodeErrorCode(error))
if steam and IsValid(stream) then myStream=stream
stream:Play()
end
end
BASS.StreamFileURL(url,callback,true)
end
[/lua]
[QUOTE=Amic;41744057]For some reason i always get error 20 (illegal parameter) when i try to play mp3 from dropbox.
Error 20 Channel nil Decode error code An illegal parameter was specified!
My quick test code:
[lua]
require'bass2'
if BASS then
local url='dl.dropboxusercontent.com/u/3766002/01-invaders-must-die.mp3'
print('URL',url)
if myStream and IsValid(myStream) then myStream:Stop() myStream:Remove() end
local function callback(stream,error) print('Error',error,'Channel',stream,'Decode error code',BASS.DecodeErrorCode(error))
if steam and IsValid(stream) then myStream=stream
stream:Play()
end
end
BASS.StreamFileURL(url,callback,true)
end
[/lua][/QUOTE]
"https://" was missing at the URL beginning. That caused error 20, bass doesn't like missing protocols.
Some other stuff you should also know:
- IsValid checks for nil too, that's why it's there.
- Stream:Remove() stops the stream before removing automatically.
Fixed test script:
[lua]
require'bass2'
if BASS then
local url='https://dl.dropboxusercontent.com/u/3766002/01-invaders-must-die.mp3'
print('URL',url)
if IsValid(myStream) then
myStream:Remove()
end
local function callback(stream,error) print('Error',error,'Channel',stream,'Decode error code',BASS.DecodeErrorCode(error))
if IsValid(stream) then
myStream=stream
stream:Play()
end
end
BASS.StreamFileURL(url,callback,true)
end[/lua]
[QUOTE=Grocel;41762542]"https://" was missing at the URL beginning. That caused error 20, bass doesn't like missing protocols.
Some other stuff you should also know:
- IsValid checks for nil too, that's why it's there.
- Stream:Remove() stops the stream before removing automatically.
Fixed test script:
[lua]
require'bass2'
if BASS then
local url='https://dl.dropboxusercontent.com/u/3766002/01-invaders-must-die.mp3'
print('URL',url)
if IsValid(myStream) then
myStream:Remove()
end
local function callback(stream,error) print('Error',error,'Channel',stream,'Decode error code',BASS.DecodeErrorCode(error))
if IsValid(stream) then
myStream=stream
stream:Play()
end
end
BASS.StreamFileURL(url,callback,true)
end[/lua][/QUOTE]
Yeah figured out that bass was nazi when it comes to protocols. Thank you for reply tho.
And if x and IsValid(x) is just my old habit.
I also wanted to ask, could you add function to reverse the stream? So you can actually play streams from end to beginning.
[QUOTE=Amic;41772999]I also wanted to ask, could you add function to reverse the stream? So you can actually play streams from end to beginning.[/QUOTE]
Not possible with BASS, since there is no function that let me do it, and gm_bass2 is more made to play endless/live streams. It's impossible for endless/live streams to be played backwards.
Grocel, there was a way to do it but it was introduced in bass_fx addon. And you would need to expose SetChannelEffect or something like this (where you set effects like reverb). Well, it doesn't matter that much, i just wanted to make one of my older addons work.
Thanks for replying.
Uh... sorry for the bump, this is the newest GM_BASS thread I could find... :tinfoil: (with google, and facepunch search tools)
I'm interested in this, not for streaming from another location though... I want something that can make a variable out of the bass intensity of a song; I'm wondering what that variable would be with this module, if any.
And again, sorry for the bump. This thread may not be too old, but I still feel uncomfortable with the bump!
Well I'm not a sound expert, but it may help if you take a look at the fftXXX functions. They put the sound's spectrum of that moment into the given table. The lowest indexes are representing the lower frequencies of a sound. Take a look in the documentation.
[QUOTE=Grocel;42235138]Well I'm not a sound expert, but it may help if you take a look at the fftXXX functions. They put the sound's spectrum of that moment into the given table. The lowest indexes are representing the lower frequencies of a sound. Take a look in the documentation.[/QUOTE]
Thank you for that!
What do I use instead of BASS.SetPosition() ???
If you want to set the seeker to a time, use BASSChannel:SetTime(float time). It doesn't work for endless streams.
If you want to set the 3D position of the sound, use BASSChannel:SetPos(vector position, vector forward, vector velocity).
It's been a long time and sorry for bumping.
I made a small update to gm_bass2:
[QUOTE]
- Added bool = Channel:IsBlockStreamed()
* This will replace Channel:IsOnline() soon as it does the same.
- Added Channel:EnableLooping(bool)
- Channels are not block streamed by default. Block streaming is active when the stream is endless.
- Channel.__index is pointing to Channel now.
- Recompiled with Source SDK 2013 and Visual Studio 2012.
[/QUOTE]
Sorry, you need to Log In to post a reply to this thread.