hi, i adopted the waveform patch from @balwyn https://forum.pdpatchrepo.info/topic/9529/do-you-often-use-the-struct-objects/17
to display and load samples in ofelia. with "space" you open a sample and with "p" you play it. at the moment it needs tab_max_index and tab_min_index from iem_tab, i dont know if theres a vanilla solution. its just a demo. and perhaps there is a better way to display waveforms? ofelia_waveform_display.zip
-
ofelia waveform display
-
@Jona [array max] and [array min] are almost the same as [tab_max_index] and [tab_min_index], although they put out the values in opposite order.
-
@ingox thanks for the vanilla solution. ofelia_waveform_display.zip it could be nice to choose an area/ show the length of the sample or to show the play position graphically inside the waveform, but i think for basic displaying its fine now. @cuinjune i can load samples when i open the pd patch, but not when i open the standalone application. do you know the reason for that or how to solve it? then it could be possible to load samples without disrupting the audio stream.
-
now it displays the current position. with the "s" key the sample stops.
ofelia_waveform_display_c.zip
-
@Jona Hi, Great work!
I just tried your patch on macOS and Windows standalone application and I could successfully load samples and play the sound.
I think it's because you're using the previous version before I fixed the path symbol of [ofSystemLoadDialog].Could you try downloading the master branch which is the lastest version?
Go to https://github.com/cuinjune/ofxOfelia and click "Clone or download" -> "Download ZIP".
And then unzip it, copy "Win32Example" and replace it with the previous one.P.S: I really like your videos. I would appreciate if you add "ofelia", "ofxOfelia" and "Pd" tags when you upload ofelia videos to Youtube. I think it will be very helpful.
-
@cuinjune thanks, you are right, i had to use the current "Win32Example". Now i can switch patterns while it does not stop playing. I also added the tags to the video, so people can find it i think it would be better to calculate the time from the current sample position and not with [realtime], its kind of a hack now, and would become a problem if i play the file backwards for example could also be nice to choose in and out points and the starting position inside the ofelia window, but the initial idea was just a little display for a sample player. this could be a good method for controlling the sample: http://www.pd-tutorial.com/english/ch03s04.html (3.4.2.3 Any position)
-
here is the sample play method from the tutorial 3.4.2.3 implemented in the ofelia interface.
"space" is for loading samples and "p" for pause and play(with regular speed):
ofelia_waveform_display_d.zip
Does anybody know if it is possible to jump to a certain position of the sample(click into the waveform) and if its possible to stop the sample so that it starts the next time at the in position(and not at the stop position/retrigger it)? or to play the sample only for one cycle? -
@Jona Hi, I'm not sure if this is what you want but I created a simple example that might be helpful to you.
You can jump to a certain position of the sample, and pause the playback. It is based on the tutorial patch from your link. I hope this helps.
-
@cuinjune thanks, thats what i wanted i will try to implement it.
-
i didnt thought its that complicated to set in and out points and play it reverse and so on without complications. i still need to understand the sampling topic better (line/phasor/samphold etc). i looked at a lot of looper and sampler patches, and i learned a lot, but for now i decided to implement a slightly modified sample-looper patch from continuum https://github.com/residuum/Puredata-abstractions because it does almost all the things i wanted. still i have to understand the sample-looper patch better. something like this https://forum.pdpatchrepo.info/topic/10677/looping-with-tabread4-after-initial-playback (initial playback) could be nice for longer samples (for searching new parts of the sample without loosing in or out point). still some bugs, but i will solve them. space opens a sample, l switches between loop mode and single shot (?), p is play, i is pause and s is stop. i dont know if it would make sense to control in and out points with the mouse inside the waveform? any other suggestions?
ofelia_waveform_display_h.zip -
@Jona Hi I just tried your patch on macOS and I got some "ofEditPolyline2dPoint: 'v1130_JonasPath3' is empty" errors on startup.
I think it happens because [ofEditPolyline2dPoint] is called before loading paths of [ofLoadPolyline2d].
I could fix it by placing [change] before [ofMap] as the screenshot below. I'm not sure if it's a safe fix though.
I agree that sampling is a wide topic and somewhat difficult to fully understand.
I'm not sure if controlling in/out points with the mouse inside the waveform would make more sense.
It sounds like a good idea to me though.
You can probably take a look at other sampler instruments(such as N.I Kontakt) to see how they did it. -
@cuinjune hi. thanks, your suggestion fixed the error. i also fixed a display error of the play position and updated the patch. i will clean up the patch if i have some time, and think about a good mouse control solution, could be nice to have an draggable in and out marker above the waveform, and a draggable play position inside the waveform, and to color the marked region (like in most audio editors). a good idea not to look only at pd instruments for understanding and inspiration one question: do you know why i need to click into the pd window to update the waveform drawing if i load a new .wav file (the drawing happens in the lower left corner of the patch)?
-
@Jona I don't understand what you mean by "I need to click into the pd window to update the waveform drawing if I load a new .wav file".
When I load a sample by pressing the space bar and then selecting a file, the waveform updates immediately.
The waveform updates well when I load new samples.
I tested this on both macOS and Windows using pd-0.48-1.
Do you mean you needed to click on the patch window to make the window have focus? -
@cuinjune exactly that. edit: its enough to make any pd window to have focus again, even with focus on the pd console it works. and the "assign $1 $2" messages get printed without focus. could it be that at my mac the ofSystemDialog window suddenly "steals" the ofelia/pd focus that is needed from ofEditPolyline2dPoint? i can only test with my mac at the moment. the very strange thing is that it worked before, and even older versions that worked well before do have the problem now. i do not remember that i changed anything before the problem occured. but nice to hear that it works at your computer. so it could be that something is wrong with my mac. thanks for testing. edit again: suddenly everything works again without changing anything, i dont know why, but i accept it
-
everything works again i cleaned up the patch, and added a colored rectangle as a region marker.
ofelia_waveform_display_i.zip
-
@Jona Great work! Even reversed playback works.
-
@cuinjune thanks. one problem was that treshhold~ outputs a also bang everytime i retrigger the sample, but i want that bang only if the phasor reaches 1 or if i press stop. treshhold~ stops the sample everytime that i retrigger it if the sampler is not in loop mode (i dont want that). so i tried to solve it with {> 0.99}. it works, but i think sadly its less accurate than treshold~. i marked the solution with red and green inside the patch. perhaps somebody knows a better way? also if the outpoint is before the inpoint the position should jump to the in point in one shot mode, to make retriggering possible. another thing that i didnt solve so far is, that it would be nice if the sample plays on without interruptions if i change in and out points. and the last thing that would be nice is to choose the sample position independently from the in and out points. and maybe copy and paste for parts of the array? perhaps thats too much, i dont know. or some beat slicer functionality? for example i really like the "recycle-like" chop suey patch from @toxonic : https://forum.pdpatchrepo.info/topic/2989/bonked-beat-slicer, but perhaps thats for a different patch. i will think about the direction it goes.
ofelia_waveform_display_j.zip -
@Jona I think you will get better answers sooner if you create a separate thread per your question if the question is about vanilla pd & sampling and not directly related to ofelia. (if the question can also be answered by non-ofelia users)
And maybe you can create and upload a simple patch which only shows the problem you want to solve so even vanilla pd users can quickly try and understand your patch.
And if you later have trouble implementing the solution in ofelia, I'd be glad to help you with that. -
@Jona Haven't looked into your patch, but the topic of detecting phasor~ values was discussed recently in the fb group. Being not very experienced with audio stuff i found one solution using threshold most convincing. Note that it detects phasor~ getting to zero instead of one, but it should be accurate:
phasortest.pdThe right outlet of threshold~ fires whenever the signal goes below 0.5 after going above 0.5, i.e. whenever it goes from one to zero.
-
@ingox thanks, it was quite similar in the patch, but i modified the values like that:
and now it seems to work fine. also the retrigger problem is solved.
@cuinjune
thanks for the suggestion. you are right, most of my questions in this thread are not ofelia related and could be ignored by non ofelia users because of the title. i thought i dont want to annoy the forum with too many threads, so i put everything into one (related to one patch). but a few extra threads could make sense. good idea with the example patchesi added a basic reverb, and a volume control. i think as a basic looper/sampler patch it could be finished:
ofelia_waveform_display_k.zip