Autor Beitrag
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 29.04.03 17:38 
Hallo,
habe da ein problem.
wenn ich die musik durchlaufen lasse(sind midi dateien) soll,
nach dem der sound beendet ist, FSOUND_IsPlaying auf False sein, richtig ?
ist es aber nicht !
warum nicht ?
ich habe es hiermiet versucht:
ausblenden Quelltext
1:
2:
3:
4:
if (Channel > -1) and  ( FSOUND_IsPlaying( Channel) = False) and (PLO > -1 ) then  begin
    EnabledButtons;
    ChangeFile;
  end;


Moderiert von user profile icontommie-lie: Code-Tags korrigiert

_________________
MFG
Michael Springwald, "kann kein englisch...."


Zuletzt bearbeitet von mimi am Di 29.04.03 19:11, insgesamt 1-mal bearbeitet
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 29.04.03 18:17 
Seit wann spielt FSound Midi-Dateien?
Du musst das mit FMusic machen, also dem Bibltiothekenteil für seuenzielle Musik. Da gibt's dann auch ein FMusic_IsPlaying, dem man den MOD-Pointer übergibt.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 29.04.03 19:11 
komisch:
in meinen verzuchen war in Channel immer ein wert eingetragen. und wenn ich bei: FSOUND_IsPlaying manuel stoppe geht es aber er macht es nicht automatisch... aber ich kann es ja mal testen:

EDIT:
habe den Titel geänert ;)

_________________
MFG
Michael Springwald, "kann kein englisch...."
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 29.04.03 19:45 
Du lädtst und spielst deine MIDI-Datei vermutlich so:
ausblenden Quelltext
1:
2:
MyMIDI := FMusic_LoadSong(Filename);
FMusic_PlaySong(MyMIDI);

Du musst aber beachten, daß weder LoadSong, noch PlaySong einen Channel erzeugen, während die FSound_PlaySound-Funktion den Channel angegeben haben möchte (und man diesen daher mit FSound_IsPlaying überprüfen kann). LoadSong gibt einen Pointer auf ein Module wieder (MyMIDI also vom Typ FMUSIC_MODULE), und den musst du mit FMusic_IsPlaying(MyMIDI) überprüfen.
Warum in Channel ein Wert eingetragen war, und was du vorher mit dem Channel gemacht hast, weiß ich nicht, dafür müsste ich sämtliche Zuweisungen an den Channel sehen.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 29.04.03 23:53 
ausblenden Quelltext
1:
2:
MyMIDI := FMusic_LoadSong(Filename); 
FMusic_PlaySong(MyMIDI);

ja genauso...
so jetzt ist mir bei meinen verzuchen noch etwas komisches aufgefallen also:
im timer überprüfe ich ob der fertig ist oder nicht und das klappt ja nicht.
wenn ich jetzt in der if schleife für FSound eine ShowMessage mache wird das ausgeüfhrt(obwol ich eine midi datei apspiele) und bei FMusk steht was im Module und im Channel stehen werte drin. komischer weiße steht in Channel immer nur 64 drin(warum ?) ich weiß es nie zu....
code im Timer:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if (Module <> NIL) and  ( FMUSIC_IsFinished( Module) = True ) and (PLO > -1 ) then begin
    EnabledButtons;
    ChangeFile;
  end;

  if (Channel <> -1) and  ( FSOUND_IsPlaying( Channel) = False) and (PLO > -1 ) then  begin
    EnabledButtons;
    ChangeFile;
  end;
end;


code für das laden und abspielen der dateien
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:
// Öffnet eine Musik Datei
procedure LoadMusikFile(DateiName:String);
var
  Datei:String;
begin
  stream:=NIL;
  module:=Nil;
  channel:=-1;

  Datei:=DateiName;

  if not FSOUND_Init(44100,32, FSOUND_Init_GlobalFocus) then begin
    Application.MessageBox(FMOD_ErrorString(FSOUND_GetError), 'FSOUND_Init', MB_OK or MB_ICONHAND);
    Halt;
  end;

  Stream := FSOUND_Stream_OpenFile(PChar(Datei), FSOUND_NORMAL, 0);

  if Stream = Nil then
    Module:=FMUSIC_LoadSong(PChar(Datei) );

  if (Module = nil) and ( Stream = NIL ) then begin
    Showmessage('Error! Opening file - ' + FMOD_ErrorString(FSOUND_GetError()));
    FSOUND_Close();
    Exit;
  end;

  if Form1.Notebook1.PageIndex <= 1 then begin 
    Form1.Caption:=Format( StrCaption + '- [ %d von %d (%d) ]', [DateiName,Index+1,FileListe.count,FileListe.count-1-Index] );
    Form1.Label14.Caption:=DateiName;
    Form1.Label16.Caption:=Format( '%d von %d (%d)', [Index+1,FileListe.count,FileListe.count-1-Index] );
  end;

  if Form1.Notebook1.PageIndex = 2 then begin
    Form1.Caption:=Format( StrCaption + ' %s - [ %d von %d (%d) ]', [DateiName,Form1.JvFileListBox1.Directory + '\' + Form1.JvFileListBox1.FileName,Form1.JvFileListBox1.ItemIndex+1,Form1.JvFileListBox1.Items.count,Form1.JvFileListBox1.Items.count-1-Form1.JvFileListBox1.ItemIndex] );
    Form1.Label14.Caption:=Format( '%s - %d von %d (%d) ', [DateiName,Form1.JvFileListBox1.Directory + '\' + Form1.JvFileListBox1.FileName,Form1.JvFileListBox1.ItemIndex+1,Form1.JvFileListBox1.Items.count,Form1.JvFileListBox1.Items.count-1-Form1.JvFileListBox1.ItemIndex] );
  end;

end;

// Spiel die Musikdatei ab
procedure PlayMusikFile;
begin
  if Stream <> nil then begin
    channel := FSOUND_Stream_Play(FSOUND_FREE, stream);
    if channel < 0 then begin
      showmessage('Error! Play - ' + FMOD_ErrorString(FSOUND_GetError()));
      FSOUND_Close();
      Form1.Timer1.Enabled:=True;
      exit;
    end;
  end
  else
    if Module <> NIL then begin
      FMUSIC_PlaySong(Module);
      Form1.Timer1.Enabled:=True;
    end;

end;

vileicht kannst du damit ja was anfagen....
ich verstehe den fehler nicht mehr... auch bei meinem spiel trit er auf.... aber immer nach den oben genannten prinzip :(
liegt das jetzt an FMOD ?

PS:
Tommie-lie, schau mal deine mails nach;)

_________________
MFG
Michael Springwald, "kann kein englisch...."
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mi 30.04.03 15:07 
Natürlich weist du dem Channel einen Wert zu. Und zwar in der PlayMusikFile-Prozedur:
mimi hat folgendes geschrieben:
ausblenden Quelltext
1:
channel := FSOUND_Stream_Play(FSOUND_FREE, stream);					

Oben (in LoadMusikFile) weist du ihr den Wert -1 (unassigned) zu und lädtst das Module und den Stream in die entsprechenden Pointer. Mit Stream_Play erzeugst du einen neuen Channel (intern) und kriegst dessen ID in die Channel-Variable gespeichert. Bei den Modules ist es was ganz anderes, weil die gar nicht das Channelsystem von FMod benutzen, sondern die Synthesizerbänke auf der Soundkarte (oder über Emulation die CPU, wenn die Soundkarte das gewünschte Feature nicht hat).
Was bei dir im Channel steht, ist also ausschließlich auf den Stream bezogen.
Wenn also die MIDI-Datei (im Module) aufgeört hat zu spielen, während der Stream aber noch weiterspielt, ist der Channel immer noch aktiv, während das Module aber ein Stop-Flag erhält, bei der Abfrage mit FMuisc_IsPlaying ein False liefert.

Warum der Channel immer 64 ist, weiß ich nicht. Könnte Zufall sein, oder du hast 63 andere FMod-Channels offen, aber ich weiß nciht genau, wie FMod seine Channel-Pointer sortiert.

mimi hat folgendes geschrieben:
ich verstehe den fehler nicht mehr... auch bei meinem spiel trit er auf.... aber immer nach den oben genannten prinzip :-(
liegt das jetzt an FMOD ?

Ich verstehe den Fehler auch nicht. Du aknnst einfach keinen Module über den Channel abfragen, weil er keinen hat. Der Code, wie du ihn gepostet hast, sieht für mich okay aus, weil du diesmal im Timer beides abfragst, den Channel und das Module.

mimi hat folgendes geschrieben:
PS:
Tommie-lie, schau mal deine mails nach;)

Wie? wo?
Ich hab' keine eMails gekriegt (niemand schreibt mir, keiner hat mich lieb :bawling:)

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 30.04.03 20:02 
doch ich hab dir eine 2 gesenden(zum thema astrar)
lol, ich habe heute mal testes gemacht, der fehler trit nur bei midi auf, sonst nirgends

_________________
MFG
Michael Springwald, "kann kein englisch...."
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mi 30.04.03 20:24 
Welcher Fehler denn?
Ich verstehe dein Problem nicht. Du kannst einfach kein Module über einen Channel abfragen. Das sind einfach zwei verschiedene Dinge. Und da du einen Stream und ein Module lädtst und abspielst, ist die Referenz auf den Channel nicht von der MIDI-Datei, sondern vom Stream (was auch immer da gespielt wird).

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 30.04.03 21:08 
habes geschaft, du hast den mein problem nicht verstanden, egal..
der fehler war:
ich hatte zuerst den Stream geladen und dann die moduele, ich hättes es umbekerht machen müssen;)

_________________
MFG
Michael Springwald, "kann kein englisch...."
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mi 30.04.03 22:39 
Stimmt, anscheinend habe ich das Problem wirklich nicht verstanden. Und tue es immer noch nicht.
Könntest du vielleicht mal genau sagen, was nicht funktioniert hat? Vielleicht kann ich's in Zukunft auch mal brauchen und muss mich dann nicht mehr mit mühseligem Bugtracking rumschlagen.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 30.04.03 23:03 
ich weiß nicht ob es an meinem qullcode irgenwie liegt, aber das problem war folgends(ich habe es nicht verstanden):
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:
procedure LoadMusikFile(DateiName:String); 
var 
  Datei:String; 
begin 
  stream:=NIL; 
  module:=Nil; 
  channel:=-1; 

  Datei:=DateiName; 

  if not FSOUND_Init(44100,32, FSOUND_Init_GlobalFocus) then begin 
    Application.MessageBox(FMOD_ErrorString(FSOUND_GetError), 'FSOUND_Init', MB_OK or MB_ICONHAND); 
    Halt; 
  end; 

  Module:=FMUSIC_LoadSong(PChar(Datei) ); 

  if Module = NIL then
  Stream := FSOUND_Stream_OpenFile(PChar(Datei), FSOUND_NORMAL, 0); 

  if (Module = nil) and ( Stream = NIL ) then begin 
    Showmessage('Error! Opening file - ' + FMOD_ErrorString(FSOUND_GetError())); 
    FSOUND_Close(); 
    Exit; 
  end; 

  if Form1.Notebook1.PageIndex <= 1 then begin 
    Form1.Caption:=Format( StrCaption + '- [ %d von %d (%d) ]', [DateiName,Index+1,FileListe.count,FileListe.count-1-Index] ); 
    Form1.Label14.Caption:=DateiName; 
    Form1.Label16.Caption:=Format( '%d von %d (%d)', [Index+1,FileListe.count,FileListe.count-1-Index] ); 
  end; 

  if Form1.Notebook1.PageIndex = 2 then begin 
    Form1.Caption:=Format( StrCaption + ' %s - [ %d von %d (%d) ]', [DateiName,Form1.JvFileListBox1.Directory + '\' + Form1.JvFileListBox1.FileName,Form1.JvFileListBox1.ItemIndex+1,Form1.JvFileListBox1.Items.count,Form1.JvFileListBox1.Items.count-1-Form1.JvFileListBox1.ItemIndex] ); 
    Form1.Label14.Caption:=Format( '%s - %d von %d (%d) ', [DateiName,Form1.JvFileListBox1.Directory + '\' + Form1.JvFileListBox1.FileName,Form1.JvFileListBox1.ItemIndex+1,Form1.JvFileListBox1.Items.count,Form1.JvFileListBox1.Items.count-1-Form1.JvFileListBox1.ItemIndex] ); 
  end; 

end;

ich musste einfach eineige code zeilen tauschen, warum weiß ich nicht :(
muss wohl an FMOD liegt, aber jetzt klapt alles prima ;)

_________________
MFG
Michael Springwald, "kann kein englisch...."
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Do 01.05.03 00:19 
Hmm...
Jupp, ist ein FMod-Problem. Ich hab' mich mal durch ein paar Zeilen Code getracet und habe folgendes herausgefunden:
FSound_Stream_OpenFile prüft nicht auf Formatkompatibilität, öffnet also einfach die MIDI-Datei. Dadurch ist der Pointer (bei dir stream) nicht nil und somit klappt auch ein FSound_Stream_Play. Dadurch wird wiederum der Channel mit einem gültigen Wert gefüllt und so weiter.
FMusic_LoadSong hingegen erkennt das Dateiformat anhand der Daten in der Datei, also völlig unabhängig. Wird keine MIDI-Datie übergeben, ist daher auch das Module nil und dein Code funktioniert wie gewünscht. Das Problem liegt darin, daß der Stream auch dann nicht nil ist, wenn die Datei (MIDI) gar nicht von der Streaming-API abgespielt werden kann.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Do 01.05.03 16:22 
gute zu wissen.
Ich hoffe dir behben diese BUGS bald.
Arbeites du auch mit FMOD ?
(wenn ja in wiefern ? in spielen ?)

_________________
MFG
Michael Springwald, "kann kein englisch...."
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Do 01.05.03 19:56 
Gelegentlich.
Benutzen tue ich es für alles mögliche, denn für einen eigenen Decoder fehlt mir das Know-How, WAV reicht mir nicht und TMediaPlayer verabscheue ich.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Do 01.05.03 20:56 
den TMediaPlayer nutzt ich auch nicht grund:
unter 2000 hatt er probleme und das nerft mich :evil:

_________________
MFG
Michael Springwald, "kann kein englisch...."