如何进声道“复制”? |
答題得分者是:syntax
|
3CS
一般會員 發表:5 回覆:9 積分:2 註冊:2003-07-31 發送簡訊給我 |
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
|
3CS
一般會員 發表:5 回覆:9 積分:2 註冊:2003-07-31 發送簡訊給我 |
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
|
3CS
一般會員 發表:5 回覆:9 積分:2 註冊:2003-07-31 發送簡訊給我 |
|
3CS
一般會員 發表:5 回覆:9 積分:2 註冊:2003-07-31 發送簡訊給我 |
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
|
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
3CS
一般會員 發表:5 回覆:9 積分:2 註冊:2003-07-31 發送簡訊給我 |
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
|
3CS
一般會員 發表:5 回覆:9 積分:2 註冊:2003-07-31 發送簡訊給我 |
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
|
3CS
一般會員 發表:5 回覆:9 積分:2 註冊:2003-07-31 發送簡訊給我 |
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
project.drp
program Project1; uses Forms, Unit1 in 'Unit1.pas' {Form1}; {$R *.res} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. unit1.dfm object Form1: TForm1 Left = 258 Top = 125 Width = 154 Height = 222 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object SpeedButton1: TSpeedButton Left = 8 Top = 8 Width = 100 Height = 22 Caption = 'Open file' Flat = True OnClick = SpeedButton1Click end object SpeedButton2: TSpeedButton Left = 8 Top = 40 Width = 100 Height = 22 Caption = 'Play All' Flat = True OnClick = SpeedButton2Click end object SpeedButton3: TSpeedButton Left = 8 Top = 72 Width = 100 Height = 22 Caption = 'Play Left Channel' Flat = True OnClick = SpeedButton3Click end object SpeedButton4: TSpeedButton Left = 8 Top = 104 Width = 100 Height = 22 Caption = 'Play Right Channel' Flat = True OnClick = SpeedButton4Click end object SpeedButton5: TSpeedButton Left = 8 Top = 136 Width = 100 Height = 22 Caption = 'Play Left as Right ' Flat = True OnClick = SpeedButton5Click end object OpenDialog1: TOpenDialog Left = 112 Top = 8 end end unit1.pas unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons, MMSystem; type TForm1 = class(TForm) OpenDialog1: TOpenDialog; SpeedButton1: TSpeedButton; SpeedButton2: TSpeedButton; SpeedButton3: TSpeedButton; SpeedButton4: TSpeedButton; SpeedButton5: TSpeedButton; procedure SpeedButton1Click(Sender: TObject); procedure SpeedButton2Click(Sender: TObject); procedure SpeedButton3Click(Sender: TObject); procedure SpeedButton4Click(Sender: TObject); procedure SpeedButton5Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; WFileName: String; FS: TMemoryStream; implementation {$R *.dfm} procedure TForm1.SpeedButton1Click(Sender: TObject); begin OpenDialog1.Filter := 'Wave File (*.wav)|*.wav'; if OpenDialog1.Execute then WFileName := OpenDialog1.FileName; end; procedure TForm1.SpeedButton2Click(Sender: TObject); begin if FileExists(WFileName) then begin FS := TMemoryStream.Create; FS.LoadFromFile(WFileName); PlaySound(PChar(FS.Memory),0,SND_SYNC SND_MEMORY); FS.Free; end; end; procedure TForm1.SpeedButton3Click(Sender: TObject); var NumByte,NumCha: Word; StarD: LongWord; Prt: Pointer; Index: Int64; begin if FileExists(WFileName) then begin FS := TMemoryStream.Create; FS.LoadFromFile(WFileName); Prt := FS.Memory; StarD := LongWord(Pointer(Integer(Prt) 16)^) 28; NumCha := Word(Pointer(Integer(Prt) 22)^); if NumCha = 2 then begin NumByte := Word(Pointer(Integer(Prt) 34)^) div 8; Index := StarD NumByte; repeat FillChar(Pointer(Integer(Prt) Index)^,NumByte,$00); Index := Index (NumByte * NumCha); until (Index >= FS.Size); PlaySound(PChar(FS.Memory),0,SND_SYNC SND_MEMORY); end; FS.Free; end; end; procedure TForm1.SpeedButton4Click(Sender: TObject); var NumByte,NumCha: Word; StarD: LongWord; Prt: Pointer; Index: Int64; begin if FileExists(WFileName) then begin FS := TMemoryStream.Create; FS.LoadFromFile(WFileName); Prt := FS.Memory; StarD := LongWord(Pointer(Integer(Prt) 16)^) 28; NumCha := Word(Pointer(Integer(Prt) 22)^); if NumCha > 1 then begin NumByte := Word(Pointer(Integer(Prt) 34)^) div 8; Index := StarD; repeat FillChar(Pointer(Integer(Prt) Index)^,NumByte,$00); Index := Index (NumByte * NumCha); until (Index >= FS.Size); PlaySound(PChar(FS.Memory),0,SND_SYNC SND_MEMORY); end; FS.Free; end; end; procedure TForm1.SpeedButton5Click(Sender: TObject); var NumByte,NumCha: Word; StarD: LongWord; Prt: Pointer; Index: Int64; begin if FileExists(WFileName) then begin FS := TMemoryStream.Create; FS.LoadFromFile(WFileName); Prt := FS.Memory; StarD := LongWord(Pointer(Integer(Prt) 16)^) 28; NumCha := Word(Pointer(Integer(Prt) 22)^); if NumCha > 1 then begin NumByte := Word(Pointer(Integer(Prt) 34)^) div 8; Index := StarD; repeat Move(Pointer(Integer(Prt) Index)^,Pointer(Integer(Prt) Index NumByte)^,NumByte); Index := Index (NumByte * NumCha); until (Index >= FS.Size); PlaySound(PChar(FS.Memory),0,SND_SYNC SND_MEMORY); end; FS.Free; end; end; end. |
3CS
一般會員 發表:5 回覆:9 積分:2 註冊:2003-07-31 發送簡訊給我 |
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
不論是DIVX,RM,AVI...等等原理是一樣的
只要你看得懂我寫的程式所做的動作
那你的問題就解決了
沒有人知道你使用的元件 Component
也不可能世界上所有 Component 都懂
所以我只能貼個範例,讓你去舉一反三,可惜你還是無法解決你的問題
我只能再給你一點建議與方向 1.基本常識 聲道的複製,只是記憶體的搬移,不管任何格式的影音文件,解碼到記憶體後,都是一樣的格式,也就是所有聲音必須解成 PCM 格式才能播放,不論是編解碼邊播放,還是全解碼後才播放,都是以下格式存在記憶體中 (以 16 bits 2 channel 為例)
---- [左聲道],[右聲道],[左聲道][右聲道],[左聲道],[右聲道],.......
bits 16 16 16 16 16 16
(以 8 bits 2 channel 為例)
---- [左聲道],[右聲道],[左聲道][右聲道],[左聲道],[右聲道],.......
bits 8 8 8 8 8 8
(以 16 bits 2 channel 為例)
---- [左聲道],[右聲道],[左聲道],[右聲道],[左聲道],[右聲道],.......
bits 16 16 16 16 16 16
(以 8 bits 單聲道)
---- [單聲道], [單聲道], [單聲道],.......
bits 8 8 8 2.Component 的認知
你必須對你所使用的 Component 是使用邊幾碼邊播放,還是載入解碼完後才播放有清楚的瞭解,並要知道資料載後的存放方式 3. 作法 --a. 解碼載入記憶體後才播放
----找到存放的方式與位置,取出Channel Number 與 Sample Size,然後套用我的程式中的轉換方式將聲道的聲音填入你要的值,看是要左到右,或是右到左,還是以其他來源的聲到取代,如果你要覆蓋聲道後能夠復原,就記得要先備份該聲道 --b. 編解碼邊播放
----找到解碼後取用該資料來播放的函式,加以改寫,可以將該函式加個前置處理,將聲道用上面的規則複製,看是要左到右,或是右到左,還是以其他來源的聲到取代,因為是編解邊播所以就不用備份了 ps.如果你要用 Medisplayer,ActiveX 之類的嵌入式播放,是無法做到你的要求的,因為其播放的目的碼是寫死的,無法加以更動,所以你要確定你所用的 Component 能對播放的資料(在播放前)加以修改。 只能到這裡再做下去,就變成我在做你的工作了
先充實你這個案子所需要的基本知識吧!
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |