@@ -89,6 +89,8 @@ SoundfilePlayer::SoundfilePlayer() : PatchObject("soundfile player"){
8989
9090 this ->width *= 2 ;
9191
92+ loaded = false ;
93+
9294}
9395
9496// --------------------------------------------------------------
@@ -106,6 +108,12 @@ void SoundfilePlayer::newObject(){
106108 this ->addOutlet (VP_LINK_AUDIO," audioFileSignal" );
107109 this ->addOutlet (VP_LINK_ARRAY," dataBuffer" );
108110 this ->addOutlet (VP_LINK_NUMERIC," finish" );
111+
112+ this ->setCustomVar (static_cast <float >(loop)," LOOP" );
113+ this ->setCustomVar (static_cast <float >(speed)," SPEED" );
114+ this ->setCustomVar (static_cast <float >(volume)," VOLUME" );
115+ this ->setCustomVar (static_cast <float >(cueIN)," CUE_IN" );
116+ this ->setCustomVar (static_cast <float >(cueOUT)," CUE_OUT" );
109117}
110118
111119// --------------------------------------------------------------
@@ -229,6 +237,24 @@ void SoundfilePlayer::updateObjectContent(map<int,shared_ptr<PatchObject>> &patc
229237
230238 }
231239
240+ if (!loaded){
241+ loaded = true ;
242+
243+ loop = static_cast <bool >(this ->getCustomVar (" LOOP" ));
244+ speed = static_cast <float >(this ->getCustomVar (" SPEED" ));
245+ volume = static_cast <float >(this ->getCustomVar (" VOLUME" ));
246+ cueIN = static_cast <double >(this ->getCustomVar (" CUE_IN" ));
247+ cueOUT = static_cast <double >(this ->getCustomVar (" CUE_OUT" ));
248+
249+ if (playhead < cueIN){
250+ playhead = cueIN;
251+ }
252+
253+ if (playhead > cueOUT){
254+ playhead = cueOUT;
255+ }
256+ }
257+
232258}
233259
234260// --------------------------------------------------------------
@@ -371,12 +397,18 @@ void SoundfilePlayer::drawObjectNodeConfig(){
371397
372398 ImGui::Spacing ();
373399 ImGui::PushItemWidth (130 *scaleFactor);
374- ImGui::SliderFloat (" SPEED" ,&speed,-1 .0f , 1 .0f );
375- ImGui::SliderFloat (" VOLUME" ,&volume,0 .0f , 1 .0f );
400+ if (ImGui::SliderFloat (" SPEED" ,&speed,-1 .0f , 1 .0f )){
401+ this ->setCustomVar (speed," SPEED" );
402+ }
403+ if (ImGui::SliderFloat (" VOLUME" ,&volume,0 .0f , 1 .0f )){
404+ this ->setCustomVar (volume," VOLUME" );
405+ }
376406 ImGui::PopItemWidth ();
377407 ImGui::Spacing ();
378408 ImGui::Spacing ();
379- ImGui::Checkbox (" LOOP " ICON_FA_REDO,&loop);
409+ if (ImGui::Checkbox (" LOOP " ICON_FA_REDO,&loop)){
410+ this ->setCustomVar (static_cast <float >(loop)," LOOP" );
411+ }
380412
381413 ImGui::Spacing ();
382414 float tempcueIN = cueIN;
@@ -385,7 +417,7 @@ void SoundfilePlayer::drawObjectNodeConfig(){
385417 if (playhead < cueIN){
386418 playhead = cueIN;
387419 }
388-
420+ this -> setCustomVar ( static_cast < float >(cueIN), " CUE_IN " );
389421 }
390422 ImGui::Spacing ();
391423 float tempcueOUT = cueOUT;
@@ -394,6 +426,7 @@ void SoundfilePlayer::drawObjectNodeConfig(){
394426 if (playhead > cueOUT){
395427 playhead = cueOUT;
396428 }
429+ this ->setCustomVar (static_cast <float >(cueOUT)," CUE_OUT" );
397430 }
398431
399432 ImGuiEx::ObjectInfo (
0 commit comments