20 May '13 - 12:48 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
  Home Help Search Login Register  
  Show Posts
Pages: [1]
1  Developments / BASS / Re: Change playback device during playback on: 18 Jan '13 - 13:23
Thanks, Ian!
It works for me.
ReplyReply Reply with quoteQuote
2  Developments / BASS / Change playback device during playback on: 13 Jan '13 - 21:10
Hello!

I want an option in my software to change the output device, even during playback. In the BASS_Init function I can set the playback device, but this way it is required to restart my application to take the effects. Is there any way to change the output device during playback or do I need to reinitialize the Bass library? Can I reinitialize Bass during playback?

I'm using C# programming language under Microsoft .NET Framework 4.
ReplyReply Reply with quoteQuote
3  Developments / BASS / Determining the length of a MIDI file on: 24 Jul '12 - 21:09
Hi!

My question is not really about using BASS. I use a synthesizer to play MIDI files, so I send MIDI messages to the device. When I play a MIDI file, I want to get the MIDI file's length and the position in seconds. Could you tell me how these values ​​were calculated in BASS?

Thank you in advance.
ReplyReply Reply with quoteQuote
4  Developments / BASS / Re: Capture Sound from my application on: 1 Jul '12 - 23:14
You can write the radio stream data to an MP3 file, but I think you can't retrieve the audio output of your software using BASS. When you create the playback stream using Bass.BASS_StreamCreateUrl, you can pass a DOWNLOADPROC delegate as a parameter. Declare a method that has three parameters: IntPtr Buffer, int Length, IntPtr User. Use Marshal.Copy to retreive data from the unmanaged code. You will also need a stream to store the data (e.g. MemoryStream, FileStream etc.). Here is an example written in C# for you:

private DOWNLOADPROC Downloader;
private FileStream Storage;

private void Download(IntPtr Buffer, int Length, IntPtr User) {
  if (this.DownloadStream != 0 && this.Storage != null && Buffer != IntPtr.Zero) {
    byte[] Buf = new byte[Length];
    Marshal.Copy(Buffer, Buf, 0, Length);

    this.Storage.Write(Buf, 0, Length);
  }
}

public void Open(string URL) {
  this.Storage = new FileStream(/* File Name */, FileMode.Create);

  this.Downloader = new DOWNLOADPROC(this.Download);
  this.DownloadStream = Bass.BASS_StreamCreateURL(URL, 0, BASSFlag.BASS_STREAM_STATUS, this.Downloader, IntPtr.Zero);
}
ReplyReply Reply with quoteQuote
5  Developments / BASS / Re: BASSMIDI - Playback using hardware or software-emulated synthesizer on: 25 Jun '12 - 22:19
Thanks for your reply. I need more than Windows MCI, because I want high-level MIDI manipulation in my software, e.g. displaying beat, modifying tempo, changing MIDI channels' volume, chord recognization, displaying notes on a virtual piano etc. Do you know any other MIDI libraries that can help me to do these?
ReplyReply Reply with quoteQuote
6  Developments / BASS / BASSMIDI - Playback using hardware or software-emulated synthesizer on: 23 Jun '12 - 22:54
Hi!

I want to implement MIDI playback in my audio player software. As I know, I need a SoundFont file to playback MIDI. Is there any way to use a hardware (eg. a synthesizer connected to MPU-401 MIDI port on a soundcard) or software-emulated (eg. Microsoft GS WaveTable Synthesizer) synthesizer as a playback device?

Thank you in advance.
ReplyReply Reply with quoteQuote
7  Developments / BASS / Re: Rewinding internet radio stream on: 14 May '12 - 18:02
Thank you for your help. I finished this part of my software completely.
ReplyReply Reply with quoteQuote
8  Developments / BASS / Re: Rewinding internet radio stream on: 11 May '12 - 17:45
I solved the rewinding too, it works great. I use FileStream instead of MemoryStream, because the PCM wave data uses a high amount of storage space. But is there any way to distinguish whether the URL is a radio stream or just an uploaded fixed-size file?
ReplyReply Reply with quoteQuote
9  Developments / BASS / Re: Rewinding internet radio stream on: 27 Apr '12 - 16:20
Thank you so much. Playing back from MemoryStream works.
ReplyReply Reply with quoteQuote
10  Developments / BASS / Re: Rewinding internet radio stream on: 26 Apr '12 - 15:58
Well, I solved the problem partially. If I comment out this line:
BytesRead |= (int)BASSStreamProc.BASS_STREAMPROC_END;
BASS calls the StreamRead function, but no sound is played because RawStorage.Read returns 0 (that means no data was read and I get a byte array that has a length of "(int) Length" with "0" values). So if I can solve the problem, I will be able to seek in the raw data.
ReplyReply Reply with quoteQuote
11  Developments / BASS / Re: Rewinding internet radio stream on: 26 Apr '12 - 14:52
That is OK, but BASS still doesn't call the StreamRead method. But why?
ReplyReply Reply with quoteQuote
12  Developments / BASS / Re: Rewinding internet radio stream on: 20 Apr '12 - 23:15
Ok, so I've created a STREAMPROC function to read MemoryStream, but BASS doesn't call this function. DSPPROC writes the data to the MemoryStream, but BASS doesn't play from it. Here's the code:

private MemoryStream RawStorage;
private DSPPROC DSPHandler;
private STREAMPROC MemStreamReader;

//DSPPROC - Works correctly and writes data to MemoryStream
private void DSPCallback(int Handle, int Channel, IntPtr Buffer, int Length, IntPtr User) {
byte[] Buf = new byte[Length];
Marshal.Copy(Buffer, Buf, 0, Length);

this.RawStorage.Write(Buf, 0, Length);
}

//STREAMPROC - BASS doesn't call it
private int StreamRead(int Handle, IntPtr Buffer, int Length, IntPtr User) {
if (this.RawStorage != null) {
byte[] Data = new byte[Length];
int BytesRead = this.RawStorage.Read(Data, 0, Length);

Marshal.Copy(Data, 0, Buffer, Length);

if (BytesRead < Length) {
BytesRead |= (int)BASSStreamProc.BASS_STREAMPROC_END;
}

return BytesRead;
}
else {
return 0;
}
}

public override bool Open(dynamic Source) {
//Some not so important calls
//...

this.RawStorage = new MemoryStream();
this.DSPHandler = new DSPPROC(this.DSPCallback);
this.MemStreamReader = new STREAMPROC(this.StreamRead);

//Create download stream and pass the DSPPROC to it. It's OK
//...

//Create playback stream
BASS_CHANNELINFO CHInfo = Bass.BASS_ChannelGetInfo(this.DownloadStream);
this.lStream = Bass.BASS_StreamCreate(CHInfo.freq, CHInfo.chans, BASSFlag.BASS_DEFAULT, this.MemStreamReader, IntPtr.Zero);

//Wait for download stream's buffer to be full and start playing download stream to receive data
//...
}

What am I doing wrong?
ReplyReply Reply with quoteQuote
13  Developments / BASS / Re: Rewinding internet radio stream on: 18 Apr '12 - 13:33
The method URLPlayback.GetStreamLength is used for displaying the available encoded data, not the playback stream's length. I think you can use the Bass.BASS_ChannelGetLength method to get the playback stream's length.

Thanks for noticing the StreamFree. I have overridden the PlaybackAbstract.FreeStream method in URLPlayback to close DownloadStream too.
ReplyReply Reply with quoteQuote
14  Developments / BASS / Re: Rewinding internet radio stream on: 17 Apr '12 - 18:30
I uploaded the code to http://std66.atw.hu/playback.txt
ReplyReply Reply with quoteQuote
15  Developments / BASS / Re: Rewinding internet radio stream on: 17 Apr '12 - 13:42
I'll upload my code when I get home from school. I haven't implemented the rewinding yet, because I'm having problems with it, so the playback works only now.

There's another problem too. This way uses lots of system memory (downloader stream, playback stream and the MemoryStream [this is required for saving the downloaded data to file] too).
ReplyReply Reply with quoteQuote
16  Developments / BASS / Re: Rewinding internet radio stream on: 16 Apr '12 - 19:02
Thanks. The playback is working. Now I can make it rewindable I think.
ReplyReply Reply with quoteQuote
17  Developments / BASS / Re: Rewinding internet radio stream on: 15 Apr '12 - 13:04
I tried an other way. Instead of creating the playback channel with BASS_StreamCreateFileUser, I created it with BASS_StreamCreatePush. In the DownloadProc method I add the received data to the playback channel using BASS_StreamPutFileData, but the BASS_ChannelGetLength function always returns -1 (even if the amount of downloaded data is more than 2MB), so the playback doesn't start.

private void Download(IntPtr Buffer, int Length, IntPtr User) {
  if (this.Storage != null) {
    if (Buffer == IntPtr.Zero) {
      this.Storage.Close();
    }
    else {
      byte[] Buf = new byte[Length];
      Marshal.Copy(Buffer, Buf, 0, Length);
      this.Storage.Write(Buf, 0, Length);
      
      Bass.BASS_StreamPutFileData(this.lStream, Buffer, Length);
    }
  }
  else {
    Bass.BASS_StreamPutFileData(this.lStream, Buffer, Length);
  }
}

public override bool Open(dynamic Source) {
  this.FreeStream(); //Free this.lStream

  this.Source = Source;

  this.Downloader = new DOWNLOADPROC(Download);
  this.Storage = new MemoryStream(); //(Re)creating MemoryStream, but in this case I don't need MemoryStream

  this.DownloadStream = Bass.BASS_StreamCreateURL(Source, 0, BASSFlag.BASS_STREAM_STATUS | BASSFlag.BASS_STREAM_BLOCK, this.Downloader, (IntPtr) 0);

  //Creating the playback stream. Channel frequency and channel count are received from DownloadStream
  BASS_CHANNELINFO CHInfo = Bass.BASS_ChannelGetInfo(this.DownloadStream);
  this.lStream = Bass.BASS_StreamCreatePush(CHInfo.freq, CHInfo.chans, BASSFlag.BASS_DEFAULT, IntPtr.Zero);

  if (this.DownloadStream == 0 && this.lStream == 0) {
    this.WriteErrorCode();
    return false;
  }

  //Waiting the buffer to be full
  bool Ready = false;
  while (!Ready) {
    int CurrentPuffer = (int)Bass.BASS_StreamGetFilePosition(this.lStream, BASSStreamFilePosition.BASS_FILEPOS_BUFFER);
    int TotalPuffer = (int)Bass.BASS_StreamGetFilePosition(this.lStream, BASSStreamFilePosition.BASS_FILEPOS_END);
    int PufferLoadInPercent = CurrentPuffer * 100 / TotalPuffer;

    if (PufferLoadInPercent == 100) {
      this.GetTags();
      Ready = true;
    }
  }

  //Start downloading
  Bass.BASS_ChannelPlay(this.DownloadStream, false);
  Bass.BASS_ChannelSetAttribute(this.DownloadStream, BASSAttribute.BASS_ATTRIB_VOL, 0);

  return true;
}

I have no idea what to do.
ReplyReply Reply with quoteQuote
18  Developments / BASS / Re: Rewinding internet radio stream on: 12 Apr '12 - 23:24
I think it will work, but I have a problem with it. I uploaded the source code here: http://users.atw.hu/std66/stream.txt

"this.Storage" is a MemoryStream. As I open a URL using the Open method, the FileProc_Close method (FILECLOSEPROC) closes the MemoryStream, so the Download method can't write data to it (but the first four seconds are played, I think it plays from MemoryStream). If I don't call the "this.Storage.Close()" method in FileProc_Close, the Bass doesn't play the radio stream (but Download method writes data to the MemoryStream) and the stream's total length is -1. But why does the FileProc_Close method close the stream?
ReplyReply Reply with quoteQuote
19  Developments / BASS / Re: Rewinding internet radio stream on: 11 Apr '12 - 23:27
Thanks. Well, I created two streams. The first one is created by Bass.BASS_StreamCreateURL (downloadstream), and the other one is by Bass.BASS_StreamCreateFile (playstream). In the DownloadProc callback I call the BASS_StreamPutData method to pass the byte array to playstream, but it receives only the first four seconds (and I can replay/rewind it any time) and downloadstream stops downloading. I don't need to use any memory streams in this way, but why does the download stops?
ReplyReply Reply with quoteQuote
20  Developments / BASS / Rewinding internet radio stream on: 10 Apr '12 - 22:13
Hi!

I'm developing my radio player software in C# and I'm using Bass.NET to play internet radios. I want to make my software able to rewind radio streams. I can store the received data in MemoryStream using the DOWNLOADPROC callback, but how can I get Bass to play from this memory stream? If I rewind the position, will Bass continue receiving data, or is it necessary to write my own data receiver method? How can I do this?

Thank you in advance.
ReplyReply Reply with quoteQuote
Pages: [1]
Powered by SMF 1.1.18 | SMF © 2013, Simple Machines