Autor Beitrag
Tavrodir
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

WinXP/98
Delphi 6 Personal
BeitragVerfasst: Mi 16.06.04 15:31 
Moin!


Ich habe aus anderen Threads hier erfahren, dass wenn man mit sounddateien arbeitet, man am besten fmod nutzt.
Habe mir das nun runtergeladen, weiß jetzt aber absolut nich, was ich damit machen soll :(
wollte eigentlich vorerst nur die länge einer mp3-datei auslesen, weiß aber noch nicht einmal, wie ich delphi dazu bringe, diese fmod datein zu nehmen... :?:

könnte mir da evtl. jmd. helfen? wollte diese frage nicht erst ins fmod-forum stellen, da hier der support einfach schneller und besser ist ;)
...wenn's geht viell. noch kurz wie ich die länge eine mp3-datei auslese...

Danke!

_________________
==Hier steht oft ein schlauer Spruch==
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 17.06.04 14:35 
also bei fmod gibts doch auch demos zum runterladen. wenn dir das nix bringt dann schau doch mal im fmod fprum auf www.fmod.de und such da nach delphi !

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

WinXP/98
Delphi 6 Personal
BeitragVerfasst: Do 17.06.04 19:57 
toll, die demos begreie ich nicht und das fmod forum is das letzte, da gibt es, wenn man "delphi" eingibt, ganze 10 ergebnisse, 2 davon sind änfängerfragen, wie man fmod nun verwendet, aber mit 0 antworten...

deswegen habe ich ja hier gefragt, werdet ihr doch sicher wissen, oder?
bekommt auch n bierchen ausgegeben ;)

_________________
==Hier steht oft ein schlauer Spruch==
Wishmaster
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Fr 18.06.04 02:31 
Hi

Ich habe auch angefangen mit Fmod rumzuspielen und habe folgende gebastelt.
Ist nur en test!!!

Fmod.dll ins Programm Verzeichnens.


ausblenden volle Höhe 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:
unit CommonTypes;


interface
 uses Windows, fmod, fmodtypes;

  const
       ENGINE_CST_OFFSET = 1000;
       ENGINE_STOP       = ENGINE_CST_OFFSET + 1;
       ENGINE_PLAY       = ENGINE_CST_OFFSET + 2;
       ENGINE_PAUSE      = ENGINE_CST_OFFSET + 3;
       ENGINE_SONG_END   = ENGINE_CST_OFFSET + 4;
       ENGINE_ON_LINE    = ENGINE_CST_OFFSET + 5;

 const
  OutputTypes: array [0..2] of TFSoundOutputTypes =
  (FSOUND_OUTPUT_WINMM, FSOUND_OUTPUT_DSOUND, FSOUND_OUTPUT_A3D);

  OutputRates: array [0..4] of Integer =
  (48000, 44100, 22050, 11025, 8000);


  Stream_LoopMode: array [0..2] of  integer =(FSOUND_LOOP_OFF,
                                              FSOUND_LOOP_NORMAL,
                                              FSOUND_LOOP_BIDI);


  CD_PlayMode: array [0..3] of  integer =(FSOUND_CD_PLAYCONTINUOUS,
                                          FSOUND_CD_PLAYONCE,
                                          FSOUND_CD_PLAYLOOPED,
                                          FSOUND_CD_PLAYRANDOM);





implementation

end.



ausblenden volle Höhe 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:
unit FModEngine;

interface
 uses Windows, Forms, Classes, SysUtils, ExtCtrls,  Dialogs,
  fmod, fmodpresets, fmodtypes, fmoderrors, CommonTypes;



Type TFModEngine = Class(TObject)
  private
    AppHWND   : THandle;
  // Mode
    Sample    :   PFSoundSample;
    Module    :   PFMusicModule;
    Stream    :   PFSoundStream;
    StreamCal : TFSoundStreamCallback;
  //
    Channel   : integer;
    DeviceIDX : integer;
    WaveFreq  : Integer;
    Volume   : integer;
    Def_Pane  : integer;
    SLoopMod    : integer;
    CDLoopMod   : integer;
    PlayerState : Integer;
    EventTimer  : TTimer;

    FValues: array [0..1] of PSingle;
    FFadeOut    : Boolean;
    FFadeIn     : Boolean;
    FFadeTime   : LongInt;


    SoundDriverList : TStringList;
    // CD Function
    CD_DriverList   : TStringList;
    CD_TrackNumber  : Integer;
    CD_DefDrive     : Integer;
  public
    procedure NotifyState (Sender : TObject);
    function  EngineState : Integer;
    constructor Create (HWND : THandle); virtual;
    destructor Destroy;
    function   Get_OutputType : integer;
    Procedure  Set_OutputTypes(TOutputType : integer);
    procedure  Set_Output(Driver: Integer);
    function   Get_SoundDriverList : TStringlist;
    function   Get_SoundDriverName : string;
   //
    Procedure Play(FileName : String);
    Procedure Set_Paused(Paused : ByteBool);
    function  Get_Paused : boolean;
    Procedure Stop;
   // Vollume
    Procedure Set_Volume(Vol : Integer);
    function  Get_Volume : Integer;
    procedure Set_Panning (Pan : Integer);
    function  Get_Panning : Integer;
    Procedure Set_Mute(Mute : ByteBool);
    function  Get_Mute : ByteBool;
    procedure Set_Pitch(Pitch : Integer);
    procedure Set_Time(SongPos : Integer);
    function  Get_Time : integer;
    function  Get_SongLen : Integer;
    Procedure Set_PlayPosition(Pos, Max : integer);
    function  Get_PlayPosition : integer;

    procedure Get_VULevel(var L_VU, R_VU : integer);
    function Get_Bitrate : Cardinal;
  // eq test
    Procedure Set_LoopMode(Mode : integer);
   end;


implementation



function TFModEngine.Get_Bitrate : Cardinal;
var lenms, lenbytes, kbps: LongInt;
begin
if Stream <> nil then
 begin
  lenms := fmod.FSOUND_Stream_GetLengthMs(stream);
  lenbytes := FSOUND_Stream_GetLength(stream);
  result := lenbytes div (lenms div 1000) div 1000 * 8 ;
 end
else
 result:= 0;
end;



{--------------- NotifyState --------------}

procedure TFModEngine.NotifyState (Sender : TObject);
begin

if Stream <> nil then
 if ((Get_Time + 0.1 >= Get_SongLen) and not (PlayerState = ENGINE_STOP)) then
  begin
    PlayerState := ENGINE_SONG_END;
   Exit;
  end;
  // test


end;

{--------------- EngineState --------------}

function TFModEngine.EngineState : Integer;
begin
    Result := PlayerState;
end;


constructor TFModEngine.Create (HWND : THandle);
var i : integer; SDriverChar, CDChar : PChar;
begin
  WaveFreq:=  44100;
  DeviceIDX := 0;
  PlayerState := ENGINE_STOP;


  FMOD_Load(nil);
//
  Set_OutputTypes(1);
  Set_Output(DeviceIDX);


//  Get Sound Driver Name
  SoundDriverList:= TStringList.Create;
    i:= 0;
 While (FSOUND_GetDriverName(i)<> nil) do
  begin
     SDriverChar:=  FSOUND_GetDriverName(i);
     inc(i);
     SoundDriverList.Add(SDriverChar);
  end;

   SLoopMod := Stream_LoopMode[0];
   CDLoopMod:= CD_PlayMode[1];
   Def_Pane := trunc(255 / 2);
   Volume  := 255;
// NotifyState
   EventTimer := TTimer.Create (nil);
   EventTimer.Interval := 1;
   EventTimer.OnTimer := NotifyState;
   EventTimer.Enabled := True;
//
end;


destructor TFModEngine.Destroy;
begin
  stop;
  FSOUND_Close
end;

{---------------------------- Output Type --------------------------}

function TFModEngine.Get_OutputType : integer;
var OutputType : TFSoundOutputTypes;
begin
 OutputType:=  FSOUND_GetOutput;
 case  OutputType of
   FSOUND_OUTPUT_WINMM:   result:= 0;
   FSOUND_OUTPUT_DSOUND:  result:= 1;
   FSOUND_OUTPUT_A3D:     result:= 2;
 end
end;

Procedure TFModEngine.Set_OutputTypes(TOutputType : integer);
begin
  FSOUND_SetOutput(OutputTypes[TOutputType]);
end;

{-------------- Sound Driver ------------}

procedure TFModEngine.Set_Output(Driver: Integer);
begin
  Stop;
  FMUSIC_StopAllSongs();
  FSOUND_Close;
  FSOUND_SetMixer(FSOUND_MIXER_QUALITY_AUTODETECT);
  FSOUND_SetBufferSize(100);
  FSOUND_SetDriver(Driver);    //Set sound driver

 if not FSOUND_Init(WaveFreq, 128, FSOUND_INIT_GLOBALFOCUS or
                                   FSOUND_INIT_ENABLESYSTEMCHANNELFX) then
  begin
    Application.MessageBox(FMOD_ErrorString(FSOUND_GetError), 'FSOUND_Init', MB_OK or MB_ICONHAND);
    Halt;
 end;
end;

function TFModEngine.Get_SoundDriverList : TStringlist;
begin
 result:=   SoundDriverList;
end;

function TFModEngine.Get_SoundDriverName : string;
var idx : integer;
begin
    idx:= FSOUND_GetDriver;
    result:= FSOUND_GetDriverName(idx);
end;


{----------------- EQ ----------------}

Procedure TFmodEngine.Set_LoopMode(Mode : integer);
begin
  SLoopMod:= Stream_LoopMode[Mode];
end;


Procedure TFmodEngine.Play(FileName : String);         // Play
begin

  FSOUND_Stream_Stop(stream);
  Stream := nil;

  Stream := FSOUND_Stream_Open(PChar(Filename), FSOUND_NORMAL or
                                                SLoopMod  or
                                                FSOUND_2D, 0, 0);

   if Stream <> nil then
     begin
       Channel := FSOUND_Stream_Play(FSOUND_FREE, Stream);
       PlayerState := ENGINE_PLAY;
     end;


   Set_Volume(Volume);
   Set_Panning(Def_Pane);

end;

Procedure TFmodEngine.Set_Paused(Paused : ByteBool);            // Set Pause
begin
  if Stream <> nil then
     FSOUND_SetPaused(Channel, Paused);

  if Paused = True then
     PlayerState := ENGINE_PAUSE
   else
     PlayerState := ENGINE_PLAY;
end;


function TFmodEngine.Get_Paused() : boolean;                    // Get Pause
begin
  if Stream <> nil then
      Result:= FSOUND_GetPaused(Channel);
end;


Procedure TFmodEngine.Stop;                                     // Stop
begin
 if Stream <> nil then
   begin
     FSOUND_Stream_Stop(Stream);
   end;
   PlayerState := ENGINE_STOP;
end;



procedure TFmodEngine.Set_Volume(Vol : Integer);                // Set Volume
begin
 if Vol > 255 then
    Vol := 255;
 if Vol < 0 then
    Vol := 0;
   FSOUND_SetVolume(channel, Vol);
  Volume:= Vol;
end;

function TFmodEngine.Get_Volume : Integer;                      // Get Volume
begin
  if Stream <> nil then
    result:=  FSOUND_GetVolume(channel)
end;


procedure TFmodEngine.Set_Panning(Pan : Integer);               // Set  Panning
begin
 //if Stream <> nil then
    if Pan > 255 then
    Pan := 255;
 if Pan < 0 then
    Pan := 0;

   FSOUND_SetPan(Channel, Pan);
   Def_Pane:= Pan;
end;

function TFmodEngine.Get_Panning : Integer;                     // Get  Panning
begin
 if Stream <> nil then
    result:=  FSOUND_GetPan(Channel);
end;

Procedure TFmodEngine.Set_Mute(Mute : ByteBool);                // Set Mute
begin
  FSOUND_SetMute(Channel, Mute)
end;

function TFmodEngine.Get_Mute : ByteBool;                       // Get Mute
begin
  result :=   FSOUND_GetMute(Channel)
end;


procedure TFmodEngine.Set_Pitch(Pitch : Integer);               // Set Pich
var freq : Integer;
begin
  // Pitch (Min = 0) < 20 > (Max = 40)
    freq := Trunc((Pitch / 20) * WaveFreq);
    if freq < 0  then
       freq := 0 ;

    if freq > 705600 then
       freq := 705600;
       FSOUND_SetFrequency(Channel, freq)
end;


procedure TFmodEngine.Set_Time(SongPos : Integer);              // Set Time
begin
 if Stream <> nil then
   FSOUND_Stream_SetTime(Stream, SongPos);
end;


function  TFmodEngine.Get_Time : integer;                       // Get Time
begin
if Stream <> nil then
   result:=  FSOUND_Stream_GetTime(Stream);

  if (PlayerState = ENGINE_STOP) or
     (PlayerState = ENGINE_SONG_END) then
      Result := 0
end;


function TFmodEngine.Get_SongLen : Integer;                     //Get SongLen
var  MilliSec : integer;
begin
  if Stream <> nil then
   begin
    MilliSec := FSOUND_Stream_GetLengthMs(stream);
    result:= MilliSec;
   end;

 if (PlayerState = ENGINE_STOP) or
    (PlayerState = ENGINE_SONG_END) then
     Result := 0
end;

Procedure TFmodEngine.Set_PlayPosition(Pos, Max : integer);          //Set Position
var  Ms, Time : integer;
begin
// Progressbar (Min = 0, Max = 100)
  if Stream <> nil then
   begin
    Ms:= FSOUND_Stream_GetLengthMs(stream);
    FSOUND_Stream_SetTime(Stream, Trunc(Ms * Pos /max)div 1);
  end
end;

function TFmodEngine.Get_PlayPosition : integer;                  //Get Position
var Ms, Time : integer;
begin
// Progressbar (Min = 0, Max = 100)
 if (Stream <> nil) then
   begin
     Ms:= FSOUND_Stream_GetLengthMs(stream) ;
     Time:= FSOUND_Stream_GetTime(Stream);
     result:= Trunc((100 / Ms) * time + 0.1);
   end
 else
  result:= 0;
  if (time >= Ms)or
     (PlayerState = ENGINE_STOP) or
     (PlayerState = ENGINE_SONG_END) then
     Result := 0
end;


procedure TFModEngine.Get_VULevel(var L_VU, R_VU: integer);       //Get VU Level
var  LevelL, LevelR: Single;
     PlevelL, PlevelR : PSingle;
begin
 if (Stream <> nil)  then
  begin
     PlevelL := @levelL;
     PlevelR:=  @levelR;

     FSOUND_GetCurrentLevels(Channel, PlevelL, PlevelR);
     L_VU:= trunc((PLevelL^)*200);
     R_VU:= trunc((PLevelR^)*200);
    end
  else
   begin
    L_VU:= 0;
    R_VU:= 0;
 end
end;


end.
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Sa 31.07.04 12:09 
hier habe ich mal eine unit veröffentlich:
www.delphi-forum.de/topic_28537.html

_________________
MFG
Michael Springwald, "kann kein englisch...."
Gandalfus
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 129



BeitragVerfasst: So 01.08.04 10:31 
benutze doch die bass.dll www.un4seen.com/
Die Hilfe ist gut, es giebt viele Delphi Beispiele und im Forum findet man auch einiges mit Delphi.

_________________
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: So 01.08.04 10:38 
was spielt die eigentlich für formate ab ???
die gleichen die FMOD kann ?

_________________
MFG
Michael Springwald, "kann kein englisch...."
Gandalfus
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 129



BeitragVerfasst: So 01.08.04 10:59 
Zitat:
BASS is an audio library for use in Windows software. It's purpose is to provide developers with the most powerful and efficient (yet easy to use), sample, stream (MP3, MP2, MP1, OGG, WAV, custom generated, WMA & CD via the add-ons), MOD music (XM, IT, S3M, MOD, MTM, UMX), MO3 music (MP3/OGG compressed MODs), and recording functions. All in a tiny DLL, under 100KB in size.


Also im wesendlichen das gleiche.

_________________
Wennn man feststellt, dass es drei Moeglichkeiten gibt, die einen Vorgang schiefgehen lassen koennen und man diese ausschaltet, entstehen automatisch drei neue Moeglichkeiten.
Jens-Erwin
Hält's aus hier
Beiträge: 8



BeitragVerfasst: Di 03.08.04 12:23 
Hallo,

komme vom Assembler-Programmieren für MC's und tue mich schwer mit Delphi und FMOD

Es ist zum Verzweifeln:

Schon wenn ich bei den uses eingebe:
windows, fmod, usw. ;


wird gemeckert:

[Fehler] fmod.pas(523): Bezeichner erwartet, aber 'FUNCTION' gefunden

Verweis auf folgenden Eintrag in der FMOD.pas

function FMOD_Load(LibName: PChar): Boolean;
begin
Result := True;
end;

Ich kann auch nicht die einzelnen Dateien: FMOD.pas und FMODtypes usw. compelieren ....immer Fehler

Hilfe Hilfe -- und Danke für Tips
iGoA
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 103

Alle Win´s
D5 Prof
BeitragVerfasst: Di 03.08.04 13:42 
Wie, es gibt nur 10 Foren-Einträge zu Delphi?! Das FMOD-Forum hat ein ganzes Unterforum für Delphi-/VB-User und da gibt´s momentan über 500 Threads mit 3300 Posts!!!

_________________
"Diner for One" objektorientiert:
"The same method as last year, Ms. Sophie?" (was für´n Schwachsinn)