Autor Beitrag
methos
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

WinXP Home, Red Hat Linux
D7
BeitragVerfasst: Di 25.05.04 11:49 
hi
könnte mir jem sagen wie ich *.mod-Datein als Hintergrund musik laufen lassen kann???
thx im vorraus

.:: methos ::.

_________________
"Was ist die Wirklichkeit? Wie definiert man das.... Realität? Wenn du darunter verstehst, was du fühlst, was du riechen, schmecken oder sehen kannst, ist die Wirklichkeit nichts weiter als elektrische Signale interpretiert von deinem Verstand."
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 25.05.04 12:26 
mit der fmod dll. gibts unter www.fmod.de

_________________
In the beginning was the word.
And the word was content-type: text/plain.
methos Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

WinXP Home, Red Hat Linux
D7
BeitragVerfasst: Di 25.05.04 12:32 
thx sieht gut aus. nur wie verwende ich das??? hab mit sowas noch nie gearbeitet. und ein noob in delphi bin ich auch noch

_________________
"Was ist die Wirklichkeit? Wie definiert man das.... Realität? Wenn du darunter verstehst, was du fühlst, was du riechen, schmecken oder sehen kannst, ist die Wirklichkeit nichts weiter als elektrische Signale interpretiert von deinem Verstand."
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 25.05.04 13:27 
also das wäre eine möglickeit. kann die medaiplayer kompo denn mod ?? probier das mal aus. ansonsten such mal hier im forum nach Suche in: Delphi-Forum, Delphi-Library FMOD

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Gandalfus
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 129



BeitragVerfasst: Di 25.05.04 20:31 
bass.dll www.un4seen.com/
Da giebt es auch eine kleine(dll grösse) Version nur für mods.

_________________
Wennn man feststellt, dass es drei Moeglichkeiten gibt, die einen Vorgang schiefgehen lassen koennen und man diese ausschaltet, entstehen automatisch drei neue Moeglichkeiten.
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Sa 29.05.04 19:24 
Zitat:

kann die medaiplayer kompo denn mod ??

Mod ist eine eigen lib und somit von mediplayer unabhänig.... es kann viele formate abspielen z.b.
Wav
Mp3, mp2
Midi, rmi
XM, S3M, IT, eins habe ich jetzt vergessen,OGG
und noch viele mehr *G*

_________________
MFG
Michael Springwald, "kann kein englisch...."
methos Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

WinXP Home, Red Hat Linux
D7
BeitragVerfasst: Sa 29.05.04 20:05 
jo aber ich will das es ohne dem wmp (win media player) geht. und fmod kapier ich ned ganz. aja weil ich kein extra thema erstellen will frag ich auch dann gelich hier. kann ich die mod in die exe einimplentieren und als hg music verwenden???

_________________
"Was ist die Wirklichkeit? Wie definiert man das.... Realität? Wenn du darunter verstehst, was du fühlst, was du riechen, schmecken oder sehen kannst, ist die Wirklichkeit nichts weiter als elektrische Signale interpretiert von deinem Verstand."
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 30.05.04 09:30 
das geht auch, such mal nach:
Suche in: Delphi-Forum, Delphi-Library RES DATEIEN
Suche in: Delphi-Library RES
fmod ist eine lib die kannst du ohne winamp benutzen, du musst nur eine dll ins windows\systen(32?) bringen und dann kann es los gehen. oder such mal bei www.torry.net/ dort habe ich mal eine mod kompo gefunden, die braucht aber glaube ich auch wieder eine dll, aber das macht ja nichts.....

_________________
MFG
Michael Springwald, "kann kein englisch...."
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 30.05.04 12:17 
die könnte man aber auch mit einbinden in die exe. ansonsten reicht es, wenn die DLL im selben ordner wie die exe liegt

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Gandalfus
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 129



BeitragVerfasst: So 30.05.04 16:33 
du nimmst die bass.dll von www.un4seen.com/
und meine unit als Hilfe:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
unit U_BassPlayer;

interface

uses
  bass, Windows, dialogs, Classes, StdCtrls, SysUtils, mmsystem;


type
  WAVHDR = packed record
    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;

  TFFTData = array[0..256] of Single;

  TBand = record
    par : BASS_FXPARAMEQ; // band of eq
    hnd : HFX; // band handle
  end;

  TBassPlayer = class
  private
    { Private declarations }
    channel: HSTREAM;

    WaveHdr: WAVHDR;  // WAV header
    recordchannel:   HRECORD;  // recording channel
    isrecording: boolean;
    EQenable: boolean;

    Modus: integer; //1= normal 2=mod Musik
    startmodplaytime: integer;
    procedure setvolume(volume: byte); //0 bis 100
    function getvolume: byte;
    function getposition: integer;
    procedure setposition(position: integer);
    function getlength: integer;        //in sekunden
    function getRightPeak: dword;
    function getLeftPeak: dword;
    function getstatus: integer;
    function getCPUusage: Single;
  public
    //Sachen für Equliser
    EQBand: array [1..10] of TBand;
    procedure updateEQ(Band1, Band2, Band3, Band4, Band5, Band6, Band7, Band8, Band9, Band10: integer);
    procedure initEQ;
    procedure removeEQ;

    constructor create(mainwindowhandle: HWND);
    destructor destroy; override;

    //Methoden fürs Internetradio
    function playNetStream(url: string): boolean;

    //Methoden zum aufnehmen
    procedure startrecording(input: integer;filename: string);
    procedure stoprecording;
    function getDatasize: int64;
    procedure setrecordvolume(input: integer;volume: integer);

    function play(filename: string): boolean;
    procedure stop;
    procedure pause;
    procedure resume;
    property CPUusage: Single read getCPUusage;
    property volume: byte read getvolume write setvolume;    //0 bis 100
    property position: integer read getposition write setposition;{in sekunden}
    property length: integer read getlength;
    property RightPeak: dword read getRightPeak;   {von 0 bis 128}
    property LeftPeak: dword read getLeftPeak;     {von 0 bis 128}
    function getfftdata: TFFTData;
    property status: integer read getstatus; //STOPPED = 0   PLAYING = 1   STALLED = 2   PAUSED  = 3
    { Public declarations }
  end;

implementation

var
  WaveStream: TFileStream;//muss leider global deklariert werden wegen callback Funktion

function TBassPlayer.getfftdata: TFFTData;
begin
  if (BASS_ChannelGetData(Channel, @Result, BASS_DATA_FFT512) = 2048) = false then
  begin
    ZeroMemory(@Result, SizeOf(Result));
  end;
end;

function TBassPlayer.getstatus: integer;
begin //STOPPED = 0   PLAYING = 1   STALLED = 2   PAUSED  = 3
  result := BASS_ChannelIsActive(channel);
end;

function TBassPlayer.getRightPeak: dword;
begin
  result := HIWORD(BASS_ChannelGetLevel(channel));
end;

function TBassPlayer.getLeftPeak: dword;
begin
  result := LOWORD(BASS_ChannelGetLevel(channel));
end;

function TBassPlayer.getCPUusage: Single;
begin
  result:= BASS_GetCPU;
end;

function TBassPlayer.getvolume: byte;
begin
  IF Modus = 1 then result := BASS_GetConfig(BASS_CONFIG_GVOL_STREAM);
  IF Modus = 2 then result := BASS_MusicGetVolume(channel,0);
end;

procedure TBassPlayer.setvolume(volume: byte);
var
  Anzahlchannels,i: integer;
begin
  IF Modus = 1 then BASS_SetConfig(BASS_CONFIG_GVOL_STREAM,volume);
  IF Modus = 2 then
  begin
    Anzahlchannels := 0;
    while (BASS_MusicGetVolume(channel,Anzahlchannels)<>-1) do inc(Anzahlchannels);
    for i:=0 to Anzahlchannels do BASS_MusicSetVolume(channel,i,volume);
  end;
end;

function TBassPlayer.getposition: integer;
var
  uptime: integer;
begin
  IF Modus = 1 then result := round(BASS_ChannelBytes2Seconds(channel,BASS_ChannelGetPosition(channel)));
  IF Modus = 2 then
  begin
    uptime:= timegettime;
    result := (uptime - startmodplaytime) div 1000;
  end;
end;

procedure TBassPlayer.setposition(position: integer);
var
  pos: dword;
begin
  IF Modus = 1 then BASS_ChannelSetPosition(Channel,BASS_ChannelSeconds2Bytes(Channel, position));
  IF Modus = 2 then
  begin
    //BASS_MusicFree(channel);
    //pos:=
    //seektime := position;
    startmodplaytime := timegettime-(position*1000);
    pos := position or $FFFF0000;
    BASS_MusicPlayEx(channel,pos,BASS_MUSIC_RAMP or BASS_MUSIC_CALCLEN,false);
  end;
end;

function TBassPlayer.getlength: integer;
begin
  IF Modus = 1 then result := round(BASS_ChannelBytes2Seconds(channel,BASS_StreamGetLength(channel)));
  IF Modus = 2 then result := round(BASS_ChannelBytes2Seconds(channel,BASS_MusicGetLength(channel,true)));
end;

function TBassPlayer.play(filename: string): boolean;
var
  i: integer;
begin
  If BASS_ChannelIsActive(channel)=1 then
  begin
    IF Modus = 1 then BASS_StreamFree(channel);
    IF Modus = 2 then BASS_MusicFree(channel);
  end;

  IF (UpperCase(ExtractFileExt(FileName)) = '.MO3') or (UpperCase(ExtractFileExt(FileName)) = '.IT') or (UpperCase(ExtractFileExt(FileName)) = '.XM') or (UpperCase(ExtractFileExt(FileName)) = '.S3M') or (UpperCase(ExtractFileExt(FileName)) = '.MTM')or (UpperCase(ExtractFileExt(FileName)) = '.MOD') or (UpperCase(ExtractFileExt(FileName)) = '.UMX') then
  begin   //mod musik
    channel := BASS_MusicLoad(False, PChar(FileName), 0, 0, BASS_MUSIC_RAMP or BASS_MUSIC_CALCLEN, 0);
    result := BASS_MusicPlay(channel);
    startmodplaytime := timegettime;
    Modus := 2
  end
  else
  begin //wav/MP3 usw
    channel:=BASS_StreamCreateFile(False,PChar(filename),0,0, BASS_STREAM_AUTOFREE);
    result := BASS_StreamPlay(channel,false,0);
    Modus := 1;
  end;

  IF EQenable then
  begin
    for i:= low(EQBand) to high(EQBand) do
    begin
      EQBand[i].hnd := BASS_ChannelSetFX(channel, BASS_FX_PARAMEQ);  //Set the EQ objects to the stream
    end;

     //Apply EQ Settings to song
    for i:= low(EQBand) to high(EQBand) do
    begin
      //BASS_FXSetParameters(EQBand[i].hnd, @EQBand[i].par);
      IF not BASS_FXSetParameters(EQBand[i].hnd, @EQBand[i].par) then showmessage('fehler')
    end;
  end;

end;

function TBassPlayer.playNetStream(url: string): boolean;
begin
  If BASS_ChannelIsActive(channel)=1 then
  begin
    IF Modus = 1 then BASS_StreamFree(channel);
    IF Modus = 2 then BASS_MusicFree(channel);
  end;

  channel:= BASS_StreamCreateURL(PChar(url), 0, BASS_STREAM_META, nil, 0 );
  IF channel= 0 then showmessage('Das kann nicht abgespielt werden.');
  result := BASS_StreamPlay(channel,false,0);
end;

procedure TBassPlayer.stop;
begin
  BASS_ChannelPause(channel);
  IF Modus = 1 then position := 0;
end;

procedure TBassPlayer.pause;
begin
  BASS_ChannelPause(channel);
end;

procedure TBassPlayer.resume;
begin
  BASS_ChannelResume(channel);
end;

constructor TBassPlayer.create(mainwindowhandle: HWND);
begin
  inherited create;;
  if BASS_GetVersion() <> MAKELONG(2,0) then
  begin
    showmessage('Falsche Version der bass.dll(benötigt wird 2.0)');
    Halt;
  end;
  BASS_Init(1, 44100, 0, mainwindowhandle,nil);

  if not BASS_RecordInit(0) then
  begin
    BASS_RecordFree;
    BASS_Free();
    MessageDlg('Cannot start default recording device!', mtError, [mbOk], 0);
    halt;
  end;

  Modus :=1;

  EQenable := false;
  
  isrecording := false;
end;


destructor TBassPlayer.destroy;
begin
  BASS_RecordFree;

  Bass_streamFree(channel);
  BASS_MusicFree(channel);

  BASS_Stop;
  BASS_Free;
  inherited destroy;
end;

// This is called while recording audio
function RecordingCallback(Handle: HRECORD; buffer: Pointer; length, user: DWord): boolean; stdcall;
begin
  // Copy new buffer contents to the memory buffer
  WaveStream.Write(buffer^, length);
  //Allow recording to continue
  Result := True;
end;


procedure TBassPlayer.startrecording(input: integer;filename: string);
var
  i: Integer;
begin
  //File Stream
  WaveStream := TFileStream.Create(filename,fmCreate);


  if WaveStream.Size > 0 then
  begin  // free old recording
    BASS_StreamFree(channel);
  end;

  // generate header for WAV file
  WaveHdr.riff := 'RIFF';
  WaveHdr.len := 36;
  WaveHdr.cWavFmt := 'WAVEfmt ';
  WaveHdr.dwHdrLen := 16;
  WaveHdr.wFormat := 1;
  WaveHdr.wNumChannels := 2;
  WaveHdr.dwSampleRate := 44100;
  WaveHdr.wBlockAlign := 4;
  WaveHdr.dwBytesPerSec := 176400;
  WaveHdr.wBitsPerSample := 16;
  WaveHdr.cData := 'data';
  WaveHdr.dwDataLen := 0;

  WaveStream.Write(WaveHdr, SizeOf(WAVHDR));
  i := 0;
  while BASS_RecordSetInput(i, BASS_INPUT_OFF) do
  begin
    i := i + 1;
  end;
  BASS_RecordSetInput(input, BASS_INPUT_ON);

  // start recording @ 44100hz 16-bit stereo
  recordchannel := BASS_RecordStart(44100, 0, @RecordingCallback, 0);
  if recordchannel = 0 then
  begin
    MessageDlg('Couldn''t start recording!', mtError, [mbOk], 0);
    WaveStream.Free;
  end;

  isrecording:= true;
end;

procedure TBassPlayer.stoprecording;
var
  i: integer;
begin
  BASS_ChannelStop(recordchannel);

  // complete the WAV header
  WaveStream.Position := 4;
  i := WaveStream.Size - 8;
  WaveStream.Write(i, 4);
  i := i - $24;
  WaveStream.Position := 40;
  WaveStream.Write(i, 4);
  WaveStream.Position := 0;
  // create a stream from the recorded data
  //channel := BASS_StreamCreateFile(false, pchar(FRecordfilename), 0, WaveStream.Size, 0);

  {if channel = 0 then
  begin
    MessageDlg('Error creating stream from recorded data!', mtError, [mbOk], 0);
  end;}

  WaveStream.Free;
end;

function TBassPlayer.getDatasize: int64;
begin
  IF isrecording then
  begin
    result:= WaveStream.Size
  end
  else
  begin
    result:=0;
  end;
end;

procedure TBassPlayer.setrecordvolume(input: integer;volume: integer);
begin
  BASS_RecordSetInput(input, BASS_INPUT_LEVEL or volume);
end;

procedure TBassPlayer.initEQ;
var
  i: integer;
begin

  for i:= low(EQBand) to high(EQBand) do
  begin
    EQBand[i].hnd := BASS_ChannelSetFX(channel, BASS_FX_PARAMEQ);  //Set the EQ objects to the stream
    EQBand[i].par.fBandwidth := 18;
    EQBand[i].par.fGain := 0;   //Wert zwichen -15 und 15
  end;

  EQBand[1].par.fCenter := 80;
  EQBand[2].par.fCenter := 170;
  EQBand[3].par.fCenter := 310;
  EQBand[4].par.fCenter := 600;
  EQBand[5].par.fCenter := 1000;
  EQBand[6].par.fCenter := 3000;
  EQBand[7].par.fCenter := 6000;
  EQBand[8].par.fCenter := 10000;
  EQBand[9].par.fCenter := 12000;
  EQBand[10].par.fCenter := 14000;

  //Apply EQ Settings to song
  for i:= low(EQBand) to high(EQBand) do
  begin
    //BASS_FXSetParameters(EQBand[i].hnd, @EQBand[i].par);
    BASS_FXSetParameters(EQBand[i].hnd, @EQBand[i].par);
  end;

  EQenable:=true;
end;

procedure TBassPlayer.removeEQ;
var
  i: integer;
begin
  for i:= low(EQBand) to high(EQBand) do
  begin
    BASS_ChannelRemoveFX(channel, EQBand[i].hnd);
  end;
  
  EQenable:=false;
end;

procedure TBassPlayer.updateEQ(Band1, Band2, Band3, Band4, Band5, Band6, Band7, Band8, Band9, Band10: integer);
var
  i: integer;
begin
  IF self.status=0 then exit; //PLayer im stop modus also nicht verändern
  EQBand[1].par.fgain := Band1;
  EQBand[2].par.fgain := Band2;
  EQBand[3].par.fgain := Band3;
  EQBand[4].par.fgain := Band4;
  EQBand[5].par.fgain := Band5;
  EQBand[6].par.fgain := Band6;
  EQBand[7].par.fgain := Band7;;
  EQBand[8].par.fgain := Band8;
  EQBand[9].par.fgain := Band9;
  EQBand[10].par.fgain := Band10;


  /// Update Band Settings
  for i:= low(EQBand) to high(EQBand) do
  begin
    IF not BASS_FXSetParameters(EQBand[i].hnd, @EQBand[i].par) then showmessage('fehler')
  end;
end;

_________________
Wennn man feststellt, dass es drei Moeglichkeiten gibt, die einen Vorgang schiefgehen lassen koennen und man diese ausschaltet, entstehen automatisch drei neue Moeglichkeiten.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 31.05.04 09:23 
poste diese unit doch mal in die units sparte des forums !!!

_________________
In the beginning was the word.
And the word was content-type: text/plain.