Bonjour,
j'ouvre un nouveau post en espérant trouver une solution parce que sinon, lentement mais surement, je vais devenir fou...
Toujours avec mes embrouilles de son, je suis parti d'un lien chez Ian (https://www.un4seen.com/forum/?topic...85684#msg85684) où l'on peut lire
ce qui, traduit du C vers Pascal, devient, après deux adaptations de noms (je ne pouvais pas utiliser son length, c'est une fonction Pascal) :
Code C : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 // If you want to get all of the file's sample data, you could do something like this... HSTREAM decoder=BASS_StreamCreateFile(FALSE, filename, 0, 0, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE); // create a stream from the file DWORD length=BASS_ChannelGetLength(decoder, BASS_POS_BYTE); // get byte length float *data=malloc(length); // allocate a buffer for the data length=BASS_ChannelGetData(decoder, data, length); // decode the stream into the buffer // do something with the data...
Ça semble trop simple pour être vrai et efficace, alors je teste avec un bouton et un mémo sur une fiche, et des "exit;" puisque ce matin Lazarus a décidé de me les casser menu menu, genre Ctrl F2 pour arrêter ne fonctionne pas, et quand le prog part en SIGSEGV ça me bloque le Bureau, je ne peux prendre aucune note dans un bloc-note, bonheur de travailler en debug à coups de "exit;" judicieusement placés... :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 decoder := BASS_StreamCreateFile(FALSE, filename, 0, 0, {pas de float BASS_SAMPLE_FLOAT | } BASS_STREAM_DECODE); // create a stream from the file datalength := BASS_ChannelGetLength(decoder, BASS_POS_BYTE); // get byte length SetLength(data, datalength); // allocate a buffer for the data alength := BASS_ChannelGetData(decoder, data, datalength); // decode the stream into the buffer // do something with the data...
(EDIT : ça s'est arrangé après un redémarrage de la machine, )
Concernant l'accès au buffer, j'ai tout tenté au pif (rajouter avant/après son nom le chapeau^ ^chinois ou l'arobase), rien ne compile à part ce qui est écrit ci-dessus.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 const SAMPLERATE = 44100; procedure TForm1.Button1Click(Sender: TObject); type TByteArray = array of byte; var f: string; decoder: HStream; buffer: TByteArray; i: integer; DataLength: int64; begin f := '/temp/audac_qq-échantillons-M16pcm.wav'; // DataLength : 22, fichier 66 bytes // f := '/temp/soundFFD1.wav'; // DataLength : 88200, fichier 88244 bytes memo.Append('f : '+f); { 1- create a stream from a file} decoder := BASS_StreamCreateFile(FALSE, PChar(f), 0, 0, {pas de float BASS_SAMPLE_FLOAT |} BASS_STREAM_DECODE); DataLength := BASS_ChannelGetLength(decoder, BASS_POS_BYTE); // en bytes SetLength(buffer, DataLength); memo.Append('DataLength : '+IntToStr(DataLength)); //exit; // ok 1st et 2nd fichiers { 2- get data} i := BASS_ChannelGetData(decoder, @buffer, DataLength); // SIGSEGV ! why ? -- ok après suppression de tous les fichiers dans ./lib //exit; memo.Append('i : '+IntToStr(i)); // 22 with 1st file, ok -- KC avec 2nd fichier ! <<<<<<<<<<< ! ! ! memo.Append('ErrorCode = '+inttostr(BASS_ErrorGetCode)); //memo.Append('buf length : '+IntToStr(length(buffer))); // SIGSEGV ! why ? Application.ProcessMessages; // pour voir les data dans le mémo { 3- do something with the data...} for i := 0 to DataLength-1 do begin memo.Append('i = '+inttostr(i)); // ok si ligne seule //memo.Append('i = '+inttostr(i)+' -- byte : '+inttostr(buffer[i])); // SIGSEGV ! why ? end; BASS_StreamFree(decoder); memo.Append('finish'); Application.ProcessMessages; // pour voir les data dans le mémo end; // SIGSEGV ici si accès au buffer ci-dessus commenté ! why ? procedure TForm1.FormCreate(Sender: TObject); begin if (HIWORD(BASS_GetVersion) <> BASSVERSION) then begin ShowMessage('Mauvaise version de la librairie BASS !'); Halt; end; if not BASS_Init(-1, SAMPLERATE, 0, nil, nil) then begin ShowMessage('BASS ne peut pas s''initialiser !'); Exit; end; end;
Les fichiers .wav concernés : 2ficspourforum.zip
Voilà.
Je ne sais pas quoi dire d'autre, alors je compte sur vous et vos idées lumineuses, moi, je n'ai plus que du brouillard dans la tête...
Et juste pour rire, après avoir longuement préparé ce post à coups de nombreux essais sur le 1er fichier, j'ai tenté avec le 2nd fichier, le gros, de 88244 octets, et ça n'a pas trainé, je vous remets la ligne concernée, au cas où elle vous aurait échappée :
Merci,
Code : Sélectionner tout - Visualiser dans une fenêtre à part memo.Append('i : '+IntToStr(i)); // 22 with 1st file, ok -- KC avec 2nd fichier, SIGSEGV comm' d'hab' ! <<<<<<<<<<< ! ! !
Partager