Dear Faust mailing list

I'm having a problem with the use of the soundfile primitive: I've developed a 
functional audio player for our lab that allows you to select files from a 
menu, play them, and pause/play/fast-forward/fast-reverse).

However, we would like to add a feature for our automated experiments: we would 
like the playback to automatically switch from one file to another in the 
soundfile list when the end of a file is reached.

All the tests I've done have put me into an infinite compile loop (my idea was 
to use a test that checks that the playback head position has reached the 
length of the loaded file in order to increment the index of the file to be 
played, but this is a bad idea since this test is necessarily recursive, since 
the length of the loaded file depends on the index itself...).

I can't therefore define the index in this way. Would you have a trick to 
advise me?


I attach the .dsp of the working drive (with selector) that I would like to 
modify to replace the file_idx menu with an automatically incrementing index at 
the end of each file.

Thank you in advance for your advice on this matter!



—— DSP CODE ——

declare name        "Reading trajectories to be synthesised by ambisonics";
declare version     "1.0";
declare author      "Eric Bavu";
declare license     "GPL";
declare copyright   "(c) Eric Bavu 2021";

import("stdfaust.lib");

//  Group in the graphical interface

LecteurGroup(x) = vgroup("[0]",x);
LecteurGroup1(x) = LecteurGroup(hgroup("[0]",x)) ;
LecteurGroup2(x) = LecteurGroup(hgroup("[2]",x)) ;
LecteurGroup3(x) = LecteurGroup(hgroup("[1]",x)) ;

// Set of audio files of measurements
s = soundfile("label[url:{
'/media/langrenne/Donnees/Deeplomatics/ambitools_subset/Encodages_ordre_0_vols_drones/Balder_2019_p0_synchro_distance_azimuth_elevation_annotations_hadrien.rf64';
'/media/langrenne/Donnees/Deeplomatics/ambitools_subset/Encodages_ordre_0_vols_drones/Baldersheim_Memsbedevmardi_27_octobre_2020_p0_synchro_distance_azimuth_elevation_annotations_hadrien.rf64';
'/media/langrenne/Donnees/Deeplomatics/ambitools_subset/Encodages_ordre_0_vols_drones/Baldersheim_Memsbedevmercredi_28_octobre_2020_p0_synchro_distance_azimuth_elevation_annotations_hadrien.rf64';
'/media/langrenne/Donnees/Deeplomatics/ambitools_subset/Encodages_ordre_0_vols_drones/Baldersheim_Memsbedevjeudi_29_octobre_2020_p0_synchro_distance_azimuth_elevation_annotations_hadrien.rf64';
'/media/langrenne/Donnees/Deeplomatics/ambitools_subset/Encodages_ordre_0_vols_drones/Baldersheim_Zylia1_mardi_27_octobre_2020_p0_synchro_distance_azimuth_elevation_annotations_hadrien.rf64';
'/media/langrenne/Donnees/Deeplomatics/ambitools_subset/Encodages_ordre_0_vols_drones/Baldersheim_Zylia1_mercredi_28_octobre_2020_p0_synchro_distance_azimuth_elevation_annotations_hadrien.rf64';
'/media/langrenne/Donnees/Deeplomatics/ambitools_subset/Encodages_ordre_0_vols_drones/Baldersheim_Zylia1_jeudi_29_octobre_2020_p0_synchro_distance_azimuth_elevation_annotations_hadrien.rf64';
'/media/langrenne/Donnees/Deeplomatics/ambitools_subset/Encodages_ordre_0_vols_drones/Baldersheim_Zylia2_mardi_27_octobre_2020_p0_synchro_distance_azimuth_elevation_annotations_hadrien.rf64';
'/media/langrenne/Donnees/Deeplomatics/ambitools_subset/Encodages_ordre_0_vols_drones/Baldersheim_Zylia2_mercredi_28_octobre_2020_p0_synchro_distance_azimuth_elevation_annotations_hadrien.rf64';
'/media/langrenne/Donnees/Deeplomatics/ambitools_subset/Encodages_ordre_0_vols_drones/Baldersheim_Zylia2_jeudi_29_octobre_2020_p0_synchro_distance_azimuth_elevation_annotations_hadrien.rf64'
}]",
5);

// Menu to select the file to be played
file_idx = LecteurGroup1(vslider("[0]Fichier à lire[style:menu{
'MemsBedev - Avril 2019':0;
'MemsBedev - Mardi 27 Octobre 2020  ':1;
'MemsBedev - Mercredi 28 Octobre 2020':2;
'MemsBedev - Jeudi 29 Octobre 2020':3;
'Zylia 1 - Mardi 27 Octobre 2020  ':4;
'Zylia 1 - Mercedi 28 Octobre 2020   ':5;
'Zylia 1 - Jeudi 29 Octobre 2020   ':6;
'Zylia 2 - Mardi 27 Octobre 2020  ':7;
'Zylia 2 - Mercredi 28 Octobre 2020   ':8;
'Zylia 2 - Jeudi 29 Octobre 2020   ':9
}]",
0,0,9,1));

// Buttons to start playback (play/pause behaviour) :

play_button2 = LecteurGroup3((button("[2]▶")));
pause_button2 = LecteurGroup3((button("[3]||")));

lecture = ( (_ >(0.5)) 
<:attach(_,LecteurGroup1(hbargraph("[1][style:led]",0,1)))) ~(+(play_button2) : 
- (pause_button2)) ;

// Fast forward and Fast rewind buttons

avance_rapide  = LecteurGroup3(button("[4] ▶▶"))  ; //
retour_rapide  = LecteurGroup3(button("[1]◀◀"))  ; //
retour_debut  = LecteurGroup3(button("[0]|◁◁"))  ; //


// File change detector in the menu :

changement_fichier = file_idx == file_idx' ;

// File player :

lecteur(s, idx) = (idx, timer(s))  : outs(s)
with {
        // Extraction of properties of the loaded file

          longueur(s) = idx,0 : s : _,si.block(outputs(s)-1) :_;

          duree_totale(x) = LecteurGroup1(hgroup("[2]Durée de l'enregistrement" 
, attach(x , heures:minutes:secondes)))
          with{
                  heures =  int((x/ma.SR):/(3600)) : 
hbargraph("[0][style:numerical][unit:heures]",0,24);
                  minutes = ma.neg : *(60) : + (int((x/ma.SR) :/(60))): 
hbargraph("[1][style:numerical][unit:minutes]",0,59) ;
                  secondes = ma.neg : *(60) : + ((x/ma.SR)) : int : 
hbargraph("[2][style:numerical][unit:secondes]",0,59) ;
                };

          // Display of position in the file :

          minuteur(x) = LecteurGroup2(hgroup("Position de la tête de 
lecture[3]" , attach(x , heures:minutes:secondes)))
          with{
                  heures =  int((x/ma.SR):/(3600)) : 
hbargraph("[0][style:numerical][unit:heures]",0,24);
                  minutes = ma.neg : *(60) : + (int((x/ma.SR) :/(60))): 
hbargraph("[1][style:numerical][unit:minutes]",0,59) ;
                  secondes = ma.neg : *(60) : + ((x/ma.SR)) : int : 
hbargraph("[2][style:numerical][unit:secondes]",0,59) ;
                };

          // Playhead position :

          timer(s) = (*(changement_fichier):*(1-retour_debut) :  max(_,1) : 
min(_,longueur(s):duree_totale ) : minuteur)~+(1*lecture : + 
(100*avance_rapide) : - (100*retour_rapide)) ;

          // Playback :

          outs(s)   = s : si.block(2), si.bus(outputs(s)-2):par(i,outputs(s)-2 
, *(1-avance_rapide)) : par(i,outputs(s)-2 , *(1-retour_rapide)) ;
        };

process = lecteur(s,file_idx)  ;


________________________________
[https://s1g.s3.amazonaws.com/e1e5417efc76b47c11d102195eb49762.png]             
Eric Bavu
Maître de Conférences HDR - Acoustique
Laboratoire de Mécanique des Structures et des Systèmes Couplés

[mobile]        06.67.12.47.94

[office]        01.40.27.21.66


LMSSC / EPN 04 Bureau 31.0E.02, 2 rue Conté, 75003, Paris, France
________________________________



_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to