|
toob
Posts: 112
|
 |
« Reply #800 on: 20 Aug '10 - 14:28 » |
Quote
|
HELP, Does anyone have an idea what's wrong with this? (bass.net, bass_fx) VB
This is what I want to happen.
1. Play an mp3 (streamFX) 2. Copy 2 seconds of streamFX into copiedclip 3. Pause streamFX 4. Play copiedclip
But I do not hear anything when copiedclip is played. Any ideas?
--------------------------------------------------------------------- 'play sub
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero) stream1 = Bass.BASS_StreamCreateFile("groove.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE) streamFX = BassFx.BASS_FX_TempoCreate(stream1, BASSFlag.BASS_FX_FREESOURCE) Bass.BASS_ChannelPlay(streamFX, True)
Music plays fine While music is playing I run the copy sub below ---------------------------------------------------------------------
'Copy sub
copiedclip = CInt(Bass.BASS_ChannelSeconds2Bytes(streamFX, 2.01)) Dim data(copiedclip / 4 - 1) As Single copiedclip = Bass.BASS_ChannelGetData(streamFX, data, copiedclip)
copiedclip has data I then pause the original music, sub below ---------------------------------------------------------------------
'pause streamFX sub
Bass.BASS_ChannelPause(streamFX)
original music paused ok I then run the play copiedclip sub below ---------------------------------------------------------------------
'play copiedclip
Bass.BASS_ChannelPlay(copiedclip, True)
No sound but copiedclip has data ---------------------------------------------------------------------
stream1, streamFX, copiedclip are all public as Integers
|
|
|
|
|
Logged
|
|
|
|
|
radio42
Posts: 4012
|
 |
« Reply #801 on: 20 Aug '10 - 16:15 » |
Quote
|
'copiedclip' is not a BASS stream handle - so how do you expect to use that with BASS_ChannelPlay!?
You might use "BASS_SampleCreate" or "BASS_StreamCreate" to create a playable stream based on your copied data.
|
|
|
|
|
Logged
|
|
|
|
|
zenon
Posts: 86
|
 |
« Reply #802 on: 29 Aug '10 - 02:19 » |
Quote
|
Hi all, my purposes to use bass.net is just for - get wav info (freq, bits and real length) from a byte[] data (because I've already open the file before) - get the data only, without the header, ever under the byte[] form. - converto the freq , render to mono and get the byte[] data modified I don't need to use any callback or play functions. Before starting (I already tried to be honest but I'm a little stuck  ) is bass the right library to do the above things? Thanks a lot (any help could be really appreciated in case )
|
|
|
|
« Last Edit: 29 Aug '10 - 02:24 by zenon »
|
Logged
|
|
|
|
|
radio42
Posts: 4012
|
 |
« Reply #803 on: 29 Aug '10 - 08:59 » |
Quote
|
Yes, you can do all this with Bass/Bass.Net:
a) get wav info (freq, bits and real length): See the BASS_ChannelGetInfo method (BASS_CHANNELINFO) to get the 'freq' and 'origres' See the BASS_ChannelGetLength method to get the 'length'
b) get the data only: When creating a decoding stream (see BASS_StreamCreateFile using the BASS_STREAM_DECODE flag) you can call BASS_ChannelGetData to get the PCM sample data as a byte[].
c) converto the freq , render to mono: You can use the BASSmix add-on and create a mono mixer channel with any target freq using BASS_Mixer_StreamCreate. You can then add the source as created in b) to that mixer via BASS_Mixer_StreamAddChannel and then call BASS_ChannelGetData on that mixer channel to get the converted sample data.
|
|
|
|
|
Logged
|
|
|
|
|
zenon
Posts: 86
|
 |
« Reply #804 on: 30 Aug '10 - 00:25 » |
Quote
|
radio42 thanks a lot for the quick answer as well as the useful infos! Maybe I'm close, but things going bad using WaveWriter: Here's the code, can you tell me please what I'm doing in a odd way?
static void Main(string[] args) { BASSError bassError; GCHandle _hGCFile;
bool isBassLibLoad = Bass.LoadMe("lib"); bool isBassMixLibLoad = BassMix.LoadMe("lib");
// open a file, is stereo 44100Hz FileStream fs = File.OpenRead("d:\\melody_space1.wav"); // get the legth of the file long length = fs.Length; // create the buffer which will keep the file in memory byte[] buffer = new byte[length]; // read the file into the buffer fs.Read(buffer, 0, (int)length); // buffer is filled, file can be closed fs.Close();
bool isBassInit = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
// now create a pinned handle, so that the Garbage Collector will not move this object _hGCFile = GCHandle.Alloc(buffer, GCHandleType.Pinned);
// create the stream (AddrOfPinnedObject delivers the necessary IntPtr) int handle = Bass.BASS_StreamCreateFile(_hGCFile.AddrOfPinnedObject(), 0L, length, BASSFlag.BASS_STREAM_DECODE);
bassError = Bass.BASS_ErrorGetCode();
// get channel info BASS_CHANNELINFO bassChannelInfo = Bass.BASS_ChannelGetInfo(handle);
bassError = Bass.BASS_ErrorGetCode();
// get raw data bool isGetData = Bass.BASS_SampleGetData(handle, buffer);
// get source sample length long sampleLength = Bass.BASS_ChannelGetLength(handle);
// byte[] of source raw data byte[] rawDataBuffer = new byte[sampleLength];
// retrieve raw data of the source on byte[] int channelTotalData = Bass.BASS_ChannelGetData(handle, rawDataBuffer, (int)sampleLength);
// reset the stream position to 0 bool isPosGood = Bass.BASS_ChannelSetPosition(handle, 0, BASSMode.BASS_POS_BYTES);
// this will be the final mixer output stream being played int mixer = BassMix.BASS_Mixer_StreamCreate(22100, 1, BASSFlag.BASS_STREAM_DECODE);
//till here everything seems going in the right way
// add channel to mixer bool isMixerGood = BassMix.BASS_Mixer_StreamAddChannel(mixer, handle, BASSFlag.BASS_STREAM_DECODE);
byte[] convertedBuffer = new byte[sampleLength];
// total data written to the new byte[] buffer int totalDataWritten = Bass.BASS_ChannelGetData(mixer, convertedBuffer, (int)sampleLength);
WaveWriter waveWriter = new WaveWriter("d:\\test.wav", mixer, true);
waveWriter.Write(convertedBuffer, totalDataWritten);
bassError = Bass.BASS_ErrorGetCode();
bool isBassLibFree = Bass.FreeMe(); bool isBassMixLibFree = BassMix.FreeMe();
}
Unfortunately test.wav sounds totally noises. Nonetheless, seems is double length while playing... What I'm doing wrong ?  Thankss!!! 
I've noticed this works: WaveWriter waveWriter = new WaveWriter("d:\\test.wav", mixer, true); short[] data = new short[32768]; while (Bass.BASS_ChannelIsActive(handle) == BASSActive.BASS_ACTIVE_PLAYING) { int length = Bass.BASS_ChannelGetData(mixer, data, 32768); if (length > 0) waveWriter.Write(data, length); }
//this doesn't work but I don't know why  //waveWriter.Write(convertedBuffer, totalDataWritten);
waveWriter.Close()Also I've noticed row while (Bass.BASS_ChannelIsActive(handle) == BASSActive.BASS_ACTIVE_PLAYING) I must put the original stream handle instead of mixer, because this last one loop infinitely.. why? Finally, is there another way to get the real sample length for >8bit and stereo? because everytime I have to check these properties and the divide by 2 or 4 (it's not a so much critical situation I know  ) Thanks !!!
|
|
|
|
« Last Edit: 30 Aug '10 - 00:51 by zenon »
|
Logged
|
|
|
|
|
radio42
Posts: 4012
|
 |
« Reply #805 on: 30 Aug '10 - 11:28 » |
Quote
|
while (Bass.BASS_ChannelIsActive(handle) == BASSActive.BASS_ACTIVE_PLAYING) A mixer channel has no real end as it is kind of continous. But BASS_ChannelGetData on a mixer channel would return 0 (or -1 in case of an error) - which can be used to end the while loop. Somwthing like: while (true) { int length = Bass.BASS_ChannelGetData(mixer, data, 32768); if (length > 0) waveWriter.Write(data, length); else break; }
|
|
|
|
|
Logged
|
|
|
|
|
vasaka
Posts: 5
|
 |
« Reply #806 on: 3 Sep '10 - 23:16 » |
Quote
|
Hi, I'm having a problem with opening WMA stream. static void Main(string[] args) { Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); var plg = Bass.BASS_PluginLoad("basswma.dll"); var radioChannel = Bass.BASS_StreamCreateURL("http://78.46.54.158:1146", 0, BASSFlag.BASS_DEFAULT, null, IntPtr.Zero); Bass.BASS_ChannelPlay(radioChannel, false); Console.ReadKey(); } It doesn't work. However, netradio from basswm24 plays it well, although it writes HTTP/1.0 400 BAD REQUEST.
|
|
|
|
|
Logged
|
|
|
|
|
ken
Posts: 630
|
 |
« Reply #807 on: 5 Sep '10 - 18:48 » |
Quote
|
Hi Bernd! I have some issues with WaveForm and WASAPI, the position of "playline" is not in sync as when using BASS only I init Wasapi like this: Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0); Bass.BASS_Init(-1, _MixFreq, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); _mixer = BassMix.BASS_Mixer_StreamCreate(_MixFreq, 2, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_MIXER_NONSTOP | BASSFlag.BASS_MIXER_POSEX); _BassWasapiHandlerOut = new BassWasapiHandler(_DeviceID, false, _MixFreq, 2, 0.2F, 0);
bool _retInit = _BassWasapiHandlerOut.Init(); Bass.BASS_PluginLoad("basswma.dll"); Bass.BASS_PluginLoad("bass_aac.dll");
Start play like this: _stream = Bass.BASS_StreamCreateFile(_Filename, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE); BassMix.BASS_Mixer_StreamAddChannel(_mixer, _stream, BASSFlag.BASS_STREAM_AUTOFREE);
WF.SyncPlayback(_stream); Bass.BASS_ChannelSetPosition(_stream, StartCue.TotalSeconds);
Waveform is drawn like your "Simple" example. For regular BASS I use _deviceLatencyBytes=0. For WASAPI I tested with: _deviceLatencyBytes = (int)Bass.BASS_ChannelSeconds2Bytes(_stream, 0.2F);
Any suggestion on how to do it correct, code? /Ken
|
|
|
|
|
Logged
|
|
|
|
|
radio42
Posts: 4012
|
 |
« Reply #808 on: 6 Sep '10 - 12:56 » |
Quote
|
Are you using BASS_ChannelGetPosition or BASS_Mixer_ChannelGetPosition to draw the position line?
|
|
|
|
|
Logged
|
|
|
|
|
ken
Posts: 630
|
 |
« Reply #809 on: 6 Sep '10 - 17:02 » |
Quote
|
Are you using BASS_ChannelGetPosition or BASS_Mixer_ChannelGetPosition to draw the position line?
Ahh, thats right. I tried some and this looks like it works, is it correct to use? long pos = BassMix.BASS_Mixer_ChannelGetPositionEx(_stream, BASSMode.BASS_POS_BYTES, (int)Bass.BASS_ChannelSeconds2Bytes(_stream, 0.2F));
|
|
|
|
|
Logged
|
|
|
|
|
radio42
Posts: 4012
|
 |
« Reply #810 on: 6 Sep '10 - 17:39 » |
Quote
|
yep
|
|
|
|
|
Logged
|
|
|
|
|
ken
Posts: 630
|
 |
« Reply #811 on: 7 Sep '10 - 10:50 » |
Quote
|
Bernd, I play some channels added to a mixer. (Wasapi) Shall I use Bass.BASS_ChannelSetSync or BassMix.BASS_Mixer_ChannelSetSync ? Now I use BASS_ChannelSetSync, it works but sometimes this sync don't execute (end of file): Bass.BASS_ChannelSetSync(_channel1, BASSSync.BASS_SYNC_END, 0, _Sync, new IntPtr(1)); //End of File
/Ken
|
|
|
|
|
Logged
|
|
|
|
|
ken
Posts: 630
|
 |
« Reply #812 on: 8 Sep '10 - 10:36 » |
Quote
|
Bernd, More problems, this time with WaveForm and recording. I "record" from a WASAPI channel. In short just add an encoder and start/stop that. That works fine, but when I add WF I get problems. WF is rendering as it should, but when I stop it hangs. First this is how I init WASAPI Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0); Bass.BASS_Init(-1, audioDevOut.MixFreq, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
_mixer = BassMix.BASS_Mixer_StreamCreate(_MixFreq, 2, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_MIXER_NONSTOP | BASSFlag.BASS_MIXER_POSEX);
_BassWasapiHandlerOut = new BassWasapiHandler(_DeviceID, false, _MixFreq, 2, 0.2F, 0);
_BassWasapiHandlerOut.Init();
_BassWasapiHandlerOut.AddOutputSource(_mixer, BASSFlag.BASS_DEFAULT);
_BassWasapiHandlerOut.Start();
if (_BassWasapiHandlerIn != null) _BassWasapiHandlerIn.Stop();
_BassWasapiHandlerIn = new BassWasapiHandler(_DeviceID, false, _MixFreq, 2, 0f, 0f); if (_BassWasapiHandlerIn.Init()) { _recordStream = _BassWasapiHandlerIn.InputChannel; _BassWasapiHandlerIn.Start(); }
Start "recording" encoding to file. private WaveForm _waveForm = null; private BaseEncoder _BaseEncoder; private DSPPROC _recDSP;
private StartRec() { EncoderTooLAME _tooLame = new EncoderTooLAME(_recordStream); _tooLame.InputFile = null; _tooLame.OutputFile = _FileName; _tooLame.TOO_Bitrate = BitRate; _tooLame.Start(null, IntPtr.Zero, false);
_BaseEncoder = _tooLame;
_waveForm = new WaveForm(); _waveForm.FrameResolution = 0.002f; _waveForm.CallbackFrequency = 0;
_recDSP = new DSPPROC(recDSPCallback); _recDSP = Bass.BASS_ChannelSetDSP(_recordStream, _recDSP, IntPtr.Zero, 0);
_waveForm.RenderStartRecording(_recordStream, 5f, 5f);
}
Callback private void vtrecDSPCallback(int handle, int channel, IntPtr buffer, int length, IntPtr user) { if (length > 0 && buffer != IntPtr.Zero) { _waveForm.RenderRecording(buffer, length); DrawWaveRec(); } }
DrawWaveRec() { image = _waveForm.CreateBitmap(500, 75, -1, -1, false); }
Stop Recording _BaseEncoderMixer.Stop(); // hangs here, but only if I use WaveForm!! _BaseEncoderMixer.Dispose(); _BaseEncoderMixer = null;
_waveForm.RenderStopRecording(); DrawWaveRec();
Any ideas? /Ken
|
|
|
|
|
Logged
|
|
|
|
|
|
|
radioDJro
Posts: 42
|
 |
« Reply #814 on: 12 Sep '10 - 09:05 » |
Quote
|
Here is a little helper class you might use to determine where/what you have 'clicked' with your mouse[...] Hi Bernd. Can you please provide a vb.net version of the class? I'm stuck at this line: public WaveFormObjectType HitObjectType = WaveFormObjectType.LowerHalf; In vb.net this should be: Public HitObjectType As WaveFormObjectType = WaveFormObjectType.LowerHalf But i get a "WaveFormObjectType is not defined" error Thank you very much, Marius.
|
|
|
|
|
Logged
|
|
|
|
|
radio42
Posts: 4012
|
 |
« Reply #815 on: 12 Sep '10 - 19:37 » |
Quote
|
I am actually no VB.Net gus - so maybe someoneelse can jump in.
|
|
|
|
|
Logged
|
|
|
|
|
Dermot
Posts: 12
|
 |
« Reply #816 on: 13 Sep '10 - 01:09 » |
Quote
|
Using Bass.net.dll/Bass.dll (both latest of post) to stream, having a issue with app crashing after char count goes over 64 in taginfo C# vs 2010 windows 7 professional 64 bit Cause.. private void MetaSync(int handle, int channel, int data, IntPtr user) { // BASS_SYNC_META is triggered on meta changes of SHOUTcast streams if (_tagInfo.UpdateFromMETA(Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_META), false, true)) { this.Invoke(new UpdateTagDelegate(UpdateTagDisplay)); } }
Error is.. System.ArgumentOutOfRangeException was unhandled Message=Text length must be less than 64 characters long. Parameter name: Text Actual value was Brought to you by Santrex.net - Far Away Feat Tiff Lacey (Adam Nickey Mix). Source=System.Windows.Forms ParamName=Text StackTrace: at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args) at System.Windows.Forms.Control.Invoke(Delegate method) at Tunes.Form1.MetaSync(Int32 handle, Int32 channel, Int32 data, IntPtr user) in C:\Users\New User\documents\visual studio 2010\Projects\Tunes\Tunes\Form1.cs:line 175
This causes app to hang and crash. line 175 is this.Invoke(new UpdateTagDelegate(UpdateTagDisplay)); Any way to either stop the 64 char limit or work around it.
|
|
|
|
|
Logged
|
|
|
|
|
radio42
Posts: 4012
|
 |
« Reply #817 on: 13 Sep '10 - 10:32 » |
Quote
|
Could it be, that it is not Bass.Net but your code which causes the exception?! E.g. a textboc, label etc. has the text ,imit property set to 64 - as Bass.Net doesn't have any 64 char limit. As you said, the exception is thrown at line 175, which is: this.Invoke(new UpdateTagDelegate(UpdateTagDisplay)); And this means the previous lines already succeeded without any exception ;-)
|
|
|
|
|
Logged
|
|
|
|
|
Dermot
Posts: 12
|
 |
« Reply #818 on: 14 Sep '10 - 18:21 » |
Quote
|
the textbox max char limit is set to 150
So i'm not sure where it is getting this limit from, could it be bass.dll?
maybe ian might have an idea why it's springing this exception, kinda stumped me at present.
|
|
|
|
|
Logged
|
|
|
|
|
Markus
Guest
|
 |
« Reply #819 on: 14 Sep '10 - 19:02 » |
Quote
|
Hello, I have following problem: I have to sound cards (onBoard + Delta LT 1010). In my application, I will init the devices on start-up: Bass.BASS_Init(device1, frequency, BASSInit.BASS_DEVICE_LATENCY, handle) // Delta Bass.BASS_Init(device2, frequency, BASSInit.BASS_DEVICE_LATENCY, handle) // onBoard When I exit the app, I will free the devices: Bass.BASS_SetDevice(device1); // Delta Bass.BASS_Free();
Bass.BASS_SetDevice(device2); // onBoard Bass.BASS_Free(); That works fine for the first start. When I will start the app again, i get following error: (it's always the onBoard device) ALSA lib pcm_dmix.c:1008:(snd_pcm_dmix_open) unable to open Bass.BASS_ErrorGetCode() returns BASS_ERROR_NOTAVAILWhen I logout an re-login, then it works. But only once. I'm using Mono 2.4. on Ubuntu 9.10 Thx Markus
|
|
|
|
|
Logged
|
|
|
|
|