Author Topic: "BASS_SAMPLE_MONO"  (Read 3799 times)

Your's fgerfr

  • Guest
"BASS_SAMPLE_MONO"
« on: 14 Jan '05 - 11:58 »
This is possible: adding flag "BASS_SAMPLE_MONO" to flag list of

function Bass_ChannelSetFlags?

Ian @ un4seen

  • Administrator
  • Posts: 20426
Re: "BASS_SAMPLE_MONO"
« Reply #1 on: 14 Jan '05 - 15:25 »
Nope, you can't switch a channel to mono after creation, but you could use a DSP function to do it, for example...

Code: [Select]
void CALLBACK MonoDSP(HDSP handle, DWORD channel, void *buffer, DWORD length, DWORD user)
{
    short *s=buffer; // assuming 16-bit...
    for (;length;length-=4,s+=2) // ...also assuming stereo
    s[1]=s[0]=(s[0]+s[1])/2; // combine left+right
}

Your's fgerfr

  • Guest
Re: "BASS_SAMPLE_MONO"
« Reply #2 on: 18 Jan '05 - 12:40 »
Catching current position of both stream and MOD music and

performing switching of "BASS_SAMPLE_MONO" Bass flag:

Quote
   

uses DirectSound;

var
channel_handle: THandle;

procedure EndSync(handle: HSYNC; channel, data, user: DWORD); stdcall;
begin
if not Form1.Loop1.Checked then begin
if Form1.ListBox1.ItemIndex < Form1.ListBox1.Items.Count-1 then begin
try
Form1.ListBox1.ItemIndex:=Form1.ListBox1.ItemIndex + 1;
Form1.ListBox1DblClick(nil)
except
Exit
end
end else begin
Form1.ListBox1.ItemIndex:=-1;
Form1.ScrollBar1.Position:=0 // seeking bar
end
end

procedure TForm1.Destroy_Channel_Handle;
begin
if channel_handle > 0 then
try
Bass_StreamFree(channel_handle);
Bass_MusicFree(channel_handle)
except
Exit
end
end;

function Bass_Channel_Load_Mono_And_Play(p: Pointer);
begin
channel_handle:=THandle(Bass_StreamCreateFile(BOOL(Abs(0)), p, 0, 0, BASS_STREAM_AUTOFREE or BASS_SAMPLE_MONO)or
Bass_MusicLoad(BOOL(Abs(0)), p, 0, 0, BASS_STREAM_AUTOFREE or BASS_MUSIC_CALCLEN or BASS_SAMPLE_MONO, 0)or
Bass_WMA_StreamCreateFile(BOOL(Abs(0)), p, 0, 0, BASS_STREAM_AUTOFREE or BASS_SAMPLE_MONO));
if channel_handle > 0 then
Bass_ChannelSetSync(channel_handle, BASS_SYNC_END, 0, EndSync, 0);
Result:=(channel_handle > 0)and(Bass_ErrorGetCode <> BASS_ERROR_NOPLAY)and(Bass_ChannelPlay(channel_handle, BOOL(Abs(0))))
end;


procedure TForm1.Mono1Click(Sender: TObject);
var
cur_pos: QWORD;
begin
case Bass_ChannelIsActive(channel_handle)of
0:
begin
try
Bass_Free;
Bass_Init(0, 48000, BASS_SAMPLE_MONO, Handle, @CLSID_DirectSound)
except raise
Exception.Create('Error has occured!')
end
end;
1, 3:
begin
cur_pos:=(Bass_ChannelGetPosition(channel_handle))or(QWORD(MAKELONG(LOWORD(Bass_ChannelGetPosition(channel_handle), HIWORD(Bass_ChannelGetPosition(channel_handle))))));
if(cur_pos <> -1)and(ListBox1.Perform(LB_GETCURSEL, 0, 0) > 0) then
try
Bass_Free;
Bass_Init(0, 48000, BASS_SAMPLE_MONO, Handle, @CLSID_DirectSound);
Destroy_Channel_Handle;
Bass_Channel_Load_And_Play(Pointer(ListBox1.Items[ListBox1.ItemIndex]));
if not Bass_ChannelSetPosition(channel_handle, cur_pos)then
Exit
except raise
Exception.Create('Error has occured!')
end
end
end
end
end;