Recording With Multichannel

Started by Moudy,

Moudy

I have ten radio stations that i want to record realtime in one PC.  How i can use BASS to solve my problem.  What kind of hardware req. ?

Can anyone help me ?

Best Regards
Moudy

Irrational86

Hardware...i would recommend a DSL or Cable modem, maybe T1 or better, (and the connection, of course)? And with bass, use 10 streams and create each with BASS_StreamCreateURL  ;D

Moudy

Thank' s XMinioNX.  But i don't want to use internet as a medium.  I'm only use radio FM/AM reciever which plugin to sound card.  So my problem is :

1.  How can i use BASS to solve this
2.  I have heard that a sound card can be pluged two FM/AM reciever. How to implement this. What type/brand of sound card i have to use.
3.  How many sound card i can plug in one PC

Sorry for my English (I'am Indonesian)

Moudy


Creadig

You can use BASS to solve the problem. Using BASS_StreamCreateFile() to record the line input of the sound card to an mp3 file in your hard drive.
Plug the FM/AM radio into the sound card using the LINE INPUT and put many sound card as you hardware support. I Use 2 of them in my PC.

If i dont answer your question, you must be more specific.

Regards!!!

Moudy

Thanx Creadig.  Could you send me sample of code how to record from sound card.  Is it possible to plug more than one FM/AM receiver to one sound card.

Moudy

bigjim

You really need a multichannel soundcard: try terratech or M Audio who do a range of reasonably priced cards.

Though how Bass would handle the card and its inputs would I think depend upon the chosen soundcards driver and how it maps its inputs as available ports to the system.

You could get two FM recievers to each soundcard if you record in mono and send one reciever to the left channel and one reciever to the right channel of your line in- then it would just be a case of using a simple recording callback in bass to save the left data to one file and the right data to another file.

If you do this with two soundcards you could record four mono recievers simultaneously with two instances of bass -theorectically. ;D

The ammount of soundcards you can plug into one pc is normally limited to I've found about 2 or 3 depending on what other cards you have in, and how many irqs etc you have free as soundcards I've found generally prefer not to share  resources.

Moudy

Dear bigjim,

Could you send me a simple code in vb or c# about how BASS recognize/init the left and right channel, how to save them.  I'll try to use the sample code from BASS 1.7.zip, but i dont understand what device i have to use (i'll try to use line in), in how to connect to left channel and right channel

Best Regards
Moudy

bigjim

I'll have a go with VB and if I can transfer the stuff I did with delphi over I'll post it later on today ;D

Smayds (Guest)

Hi Moudy,

We use a string of USB sound cards to do this very thing at the radio station I work at. Their brands escape me at the moment... But I know they are all different (you know, it really wouldn't be that hard for manufacturers to build in support for more than one installed product in their drivers... grrrrr...). Just about anything will do, they're cheap, and of course sound GREAT compared to most ordinary PC sound cards (they're outside the box, so much less noise).

-Ayden

Moudy

Thank Smayds.  Could you give/send me the code how to implement this ?

For Bigjim, if you don't mind, you can send  me the code in delphi.

"Happy New Year for all of you"

Moudy

Smayds

Hi Moudy,

We use a commercial multichannel recording software package, but Bass can do it just as well (of course). Just take a look at the RecordTest demo. You simply spawn ten instances of a small recording thread, each one looking at a different sound device/channel.

If you need more specific help, I can knock you a demo together (Delphi or C++, but you'd have to ask very nicely for C++! I haven't used it in ages & would have to dust off my C++Builder CD's  ;D )

-Ayden

bigjim

#11
coulnt get a vb translation to work poroperly-
almost had it but the lack of pointers deterred me......

but heres a bit of delphi code....for once i've just posted the full unit because this project is biggish..

right......
a new form
*) two buttons on a form button1(record), button2(stop)
*) a combo box ..........

it does work...
if you are set on using vb and cant convert the method i use then just compile the contents of the recording callback to a dll and pass it the buffer contents length and required filename, etc. or I can do it for you.
........here you go

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Bass, ExtCtrls;

type
  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    Button1: TButton;
    Button2: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure RecStart;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
    WaveStreamL: TFileStream; // Left file stream
    WaveStreamR: TFileStream; // Right file stream
  public
    { Public declarations }
  end;

  type
  WAVHDR = packed record // PCM Wav file header type
    riff: array[0..3] of Char;
    len: DWord;
    cWavFmt: array[0..7] of Char;
    dwHdrLen: DWord;
    wFormat: Word;
    wNumChannels: Word;
    dwSampleRate: DWord;
    dwBytesPerSec: DWord;
    wBlockAlign: Word;
    wBitsPerSample: Word;
    cData: array[0..3] of Char;
    dwDataLen: DWord;
  end;

  type
  fakearr = array[0..1] of smallint; // Temporary array type to work with buffers

var
  Form1: TForm1;
  rec_i: Integer;
  WaveHdrL: WAVHDR; // left Channel type
  WaveHdrR: WAVHDR; // Right Channel type
  leftdata : array of smallint; // Left channel array
  rightdata : array of smallint; // Right channel array
  Ldt : ^fakearr; // Temp array pointer

implementation

{$R *.dfm}

function RecordCallback(Buffer: Pointer; Length, User: DWord): Bool; stdcall;
var
h,j : integer;
begin
  Ldt := buffer; // assign the buffer to a useable array type
  setlength(leftdata, length div 2); // Make a buffer for the L&R channels
  setlength(rightdata, length div 2);
  j := 0;
  for h := 0 to length div 4 do // Loop through the array
  begin
  leftdata[h] := Ldt[j]; // Left channel is the first bit of data
  rightdata[h] := Ldt[j+1]; // Right channel is the second bit of data
  j := j + 2 // And so on
  end;
  buffer := leftdata; // Just use the buffer for ease
  Form1.WaveStreamL.Write(buffer^, Length div 2); // Write the left channel
  buffer := rightdata;
  Form1.WaveStreamR.Write(buffer^, Length div 2); // Write the right channel
  Result := True; // Function successful
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
  dName: PChar;
begin
BASS_Init(-1, 44100, 0, Handle); // Init Bass
Bass_Start; // Start Bass
BASS_RecordInit(-1); // Init Record
 i := 0;
 dName := BASS_RecordGetInputName(i);
  while dName <> nil do // Populate combo box with input names
  begin
    ComboBox1.Items.Add(StrPas(dName));
    i := i + 1;
    dName := BASS_RecordGetInputName(i);
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  BASS_Stop; // Stop Bass
  BASS_RecordFree; // Free Record Streams
  BASS_Free; // Finally free bass
end;


Procedure TForm1.RecStart;
begin
////////////////////////////// Left Channel attribs
    WaveHdrL.riff := 'RIFF';
    WaveHdrL.len := 36;
    WaveHdrL.cWavFmt := 'WAVEfmt ';
    WaveHdrL.dwHdrLen := 16;
    WaveHdrL.wFormat := 1;
    WaveHdrL.wNumChannels := 1;
    WaveHdrL.dwSampleRate := 44100;
    WaveHdrL.wBlockAlign := 4;
    WaveHdrL.dwBytesPerSec := 176400;
    WaveHdrL.wBitsPerSample := 16;
    WaveHdrL.cData := 'data';
    WaveHdrL.dwDataLen := 0;
////////////////////////////// Right channel attribs
    WaveHdrR.riff := 'RIFF';
    WaveHdrR.len := 36;
    WaveHdrR.cWavFmt := 'WAVEfmt ';
    WaveHdrR.dwHdrLen := 16;
    WaveHdrR.wFormat := 1;
    WaveHdrR.wNumChannels := 1;
    WaveHdrR.dwSampleRate := 44100;
    WaveHdrR.wBlockAlign := 4;
    WaveHdrR.dwBytesPerSec := 176400;
    WaveHdrR.wBitsPerSample := 16;
    WaveHdrR.cData := 'data';
    WaveHdrR.dwDataLen := 0;
//////////////////////////////// Set up two files for each channel
    WaveStreamL := TFileStream.Create(ChangeFileExt('left', '.wav'), fmCreate);
    WaveStreamR := TFileStream.Create(ChangeFileExt('right', '.wav'), fmCreate);
    WaveStreamL.Write(WaveHdrL, SizeOf(WAVHDR)); // Write the Left header
    WaveStreamR.Write(WaveHdrR, SizeOf(WAVHDR)); // Write the Right header
    rec_i := 0;
    while BASS_RecordSetInput(rec_i, BASS_INPUT_OFF) do rec_i := rec_i + 1;
    BASS_RecordSetInput(ComboBox1.ItemIndex, BASS_INPUT_ON);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
RecStart; // Call start record functionto write headers
BASS_RecordStart(44100, 0, @RecordCallback, 0); // Start Recording
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
    BASS_ChannelStop(RECORDCHAN); // Stop the recording channel
/////////////////////////// Write the Left Channels end
    WaveStreamL.Position := 4;
    rec_i := WaveStreamL.Size - 8;
    WaveStreamL.Write(rec_i, 4);
    rec_i := rec_i - $24;
    WaveStreamL.Position := 40;
    WaveStreamL.Write(rec_i, 4);
    WaveStreamL.Free;
/////////////////////////// Write the Right Channels end
    WaveStreamR.Position := 4;
    rec_i := WaveStreamR.Size - 8;
    WaveStreamR.Write(rec_i, 4);
    rec_i := rec_i - $24;
    WaveStreamR.Position := 40;
    WaveStreamR.Write(rec_i, 4);
    WaveStreamR.Free;
end;

end.

Hope this helps

Moudy

Thanks bigjim.  I've already implement your code in c#. Many thanks for your help. Now, bigjim i have a problem in what kind of cable i have to us, so left channel and right channel can be separated.

Moudy

bigjim

You can probably buy something to do it- but if you want to make your own cables I've found www.maplin.co.uk a good supplier for this country- you may have a similar near where you live.

Say you want to plug two recievers to the one input assuming each reciever has a left and right phono output and the input to your soundcard is a stereo jack you would make your cables or adapt a similar one like this:

Reciver1 Left Phono + to Jack Left
Reciver1 Left Phono - to Jack Ground
Reciver1 Right Phono + to Jack Left
Reciver1 Right Phono - to Jack Ground

Reciver2 Left Phono + to Jack Right
Reciver2 Left Phono - to Jack Ground
Reciver2 Right Phono + to Jack Right
Reciver2 Right Phono - to Jack Ground

This arrangement will give you reciever one on the left channel and reciever two on the right channel- I think its good practice to use a resistor when mixing down two channels to mono but it should work.

I'll try and attach a picture to make it more clear: