Help with audio patch on off based on some condition
@ddw_music said:
Played a long time, then paused a short time:
that scenario should resume the playback and not start from the beginning
so basically there is two variables shortTime for counting time when audio is not playing and longTime for counting time when audio is playing.
TrackTimeAudioPlaying;
shortTime = 5 sec;
longTime = 20 sec;
audioPlaying = True;
if TimeAudioPlaying >= longTime
pause track;
if next press < shortTime:
resume track;
if next press>shortTime:
start for beginning.
assuming a situation of long track of 20 minutes.
What I'm trying to do is that when someone press the button the track will start playing. if he press again the track will pause and a counter will start. if he didn't press again within 10 sec the track will start from the beginning at next press, if he did press the track will resume.
after 30 sec of track playing without any press it will pause. if next press is less then 10 seconds since the pause it will resume, if next press is after 10 seconds it will start from the beginning.
pd to play up to 15 audio files with Pi2
Here is my patch for the moment:
When I press btn 1 it play track 1 when I press btn 2 it should start track 2 (and stop track 1) but this is not happening. only a second press will start the track.
Why is that? can you see m mistake?
pd to play up to 15 audio files with Pi2
No need for playing track at the same time. 15 buttons that each button will play a corresponding track.
If track 1 is playing and someone press button 2 (correspond to track 2) the track that was playing (track number 1) will stop and track number 2 will start. Only 1 track that playing at a given time.
Do I need to load the 15 tracks to buffer in advanced? or I can read them from the sd card? Any suggested system for that?
How to play multiple audio files from sd card - best method
@omer1789 It is very difficult to stop the playback using [phasor~] because detecting the instant that [phasor~] wraps back to zero is unreliable.
You can use [line~] or better [vline~] instead of [phasor~]
They will do the same.... create a ramp from 0 to 1, but just once.
Otherwise, [readsf~] is easier like this.......... cart_wav_simple.pd
But because it uses [switch~] to pause playback you should open multiple copies of the cart..... one for each track..... rather than copying the patch numerous times into the same window.
[switch~] will then only turn off and on dsp processing (and so pause playback) for that individual window.
Because the name of the track will be lost (because all the copies of the abstraction are identical) you will have to add the name as an argument...... so [cart_wav_simple 07023329] and within the abstraction [open /Users/....../music/$1.wav] The abstraction will then open the track with the argument as its track name.
If you set the GOP (graph on parent) to on for each abstraction with the red box just around the playback controls then you can have a neat main patch with just those controls showing.
Right-click to properties within the abstraction to set the GOP and then save the abstraction.
David.
Question(s) about [mrpeach/midifile]
@whale-av said:
@dfkettle So you have the Martin Peach 2018 files through Deken.
Yes, I installed it through Deken. Isn't that the latest version?
Martin had mentioned the meta messages on the list though, and they are in the 2018 help file.
I haven't tried any of the meta messages yet, although I'm going to eventually. I'm just using [track n( messages to set the track no.
I have played a little with them this afternoon and have not so far been able to ascertain what exactly is required but....... I did get multiple tracks, although they are not named.
Open the .mid file
Then send into [midifile] [meta 0 678( ...... could maybe be [meta 0 0(......??
Then [meta 0 679( ...... again, could be [meta 0 1( ......?
Then [meta 3 woof( .........or whatever name you want but it doesn't seem to give a name.
Then [meta 3 lala( ...... same as above)
Then start recording and send [track 0( and send in some notes.
Then send [track 1( and some notes.That gave me 2 tracks but a load of "no running status" messages
I haven't tried the other [meta f s( messages yet.
I think I asked earlier, but is anyone maintaining his code? Is there a github repository where I can ask questions?
Alternatively, is there any other external that I could use instead of Cyclone or MrPeach to record and save MIDI data? I've reverted to using Cyclone for now, but it seems to me that the last MIDI event sometimes gets dropped in the saved file. There's no "flush" function in [cyclone/seq], afaik. Is it possible that all the data isn't getting written to the file?
Question(s) about [mrpeach/midifile]
@dfkettle So you have the Martin Peach 2018 files through Deken.
I had been trying raw mode..... hex messages into [midifile] to set the headers.... but it was unrewarding hard work. Martin had mentioned the meta messages on the list though, and they are in the 2018 help file.
I have played a little with them this afternoon and have not so far been able to ascertain what exactly is required but....... I did get multiple tracks, although they are not named.
Open the .mid file
Then send into [midifile] [meta 0 678( ...... could maybe be [meta 0 0(......??
Then [meta 0 679( ...... again, could be [meta 0 1( ......?
Then [meta 3 woof( .........or whatever name you want but it doesn't seem to give a name.
Then [meta 3 lala( ...... same as above)
Then start recording and send [track 0( and send in some notes.
Then send [track 1( and some notes.
That gave me 2 tracks but a load of "no running status" messages
I haven't tried the other [meta f s( messages yet.
Yes [flush( closes the file after writing and although Martin Peach mentioned on the Pdlist needing to rewind before writing that doesn't seem necessary.
David.
Question(s) about [mrpeach/midifile]
@dfkettle I would expect read/write to be first as they get the file/set the header for writing (MThd).
Then the track.... as that means moving on within the file to the next header for a read, or writing a Track header for a write (MTrk).
That's the order I tried first, but it didn't seem to work. Anyway, I changed it back again to agree with what you suggest, but it still seems to disregard the track number (it plays the track even though I specified track 0 when writing and track 1 when reading. Here's the latest version:
P.S. What does your midifile-help file look like?...... is it this one from 2010?
So for a write the track would go between "1" and "2".
Essentially, although it says "Martin Peach, 2010 - 2018" on mine. However, I'm wondering now how I would create a file with more than one track, if you have to specify the track number between steps "1" and "2". (in other words, before you start recording). Can you change the track number after you've started recording? How could you create two tracks that play at the same time? Maybe that isn't even supported by this library.
EDIT: Does the 'flush' message close the file after writing? I don't see anything in the help file about a 'close' message, so I'm assuming it does.
Question(s) about [mrpeach/midifile]
Up until now, I've been using [cyclone/seq], [cyclone/midiformat] and [cyclone/midiparse] to read and write MIDI files. They're simple to use, but don't support as many features as [mrpeach/midifile], it seems to me. However, I'm struggling to understand the documentation in the help file. There are lots of examples of the different messages you can send to [midifile], but it isn't always clear in what order they should be sent (btw, I have that complaint about a lot of help files, not just this one). I think that might be the cause of this problem, but I'm not sure. I'm writing to track 0 (I think), but when I read the file, it seems to play all tracks, regardless of which one I specify. The documentation states that you should specify -1 to play back all tracks. But it seems to be doing that anyway, even though I specified track 1 when reading. I think the problem may be that I'm not sending the messages in the correct order.
I understand that the original developer, Martin Peach, passed away a couple of years ago. Is anyone currently maintaining this external?
Ganymede: an 8-track, semi-automatic samples-looper and percussion instrument based on modulus instead of metro
Ganymede.7z (includes its own limited set of samples)
Background:
Ganymede was created to test a bet I made with myself:
that I could boil down drum sequencing to a single knob (i.e. instead of writing a pattern).
As far as I am concerned, I won the bet.
The trick is...
Instead of using a knob to turn, for example, up or down a metro, you use it to turn up or down the modulus of a counter, ie. counter[1..16]>[mod X]>[sel 0]>play the sample. If you do this then add an offset control, then where the beat occurs changes in Real-Time.
But you'll have to decide for yourself whether I won the bet. .
(note: I have posted a few demos using it in various stages of its' carnation recently in the Output section of the Forum and intend to share a few more, now that I have posted this.)
Remember, Ganymede is an instrument, i.e. Not an editor.
It is intended to be "played" or...allowed to play by itself.
(aside: specifically designed to be played with an 8-channel, usb, midi, mixer controller and mouse, for instance an Akai Midimix or Novation LaunchPad XL.)
So it does Not save patterns nor do you "write" patterns.
Instead, you can play it and save the audio~ output to a wave file (for use later as a loop, song, etc.)
Jumping straight to The Chase...
How to use it:
REQUIRES:
moonlib, zexy, list-abs, hcs, cyclone, tof, freeverb~ and iemlib
THE 7 SECTIONS:
- GLOBAL:
- to set parameters for all 8 tracks, exs. pick the samples directory from a tof/pmenu or OPEN_IND_DIR (open an independent directory) (see below "Samples"for more detail)
- randomizing parameters, random all. randomize all every 10*seconds, maximum number of bars when randomizing bars, CLR the randomizer check boxes
- PLAY, L(imited) or I(nfinite) counter, if L then number of bars to play before resetting counter, bpm(menu)
- MSTVOL
- transport/recording (on REC files are automatically saved to ./ganymede/recordings with datestamp filename, the output is zexy limited to 98 and the volume controls the boost into the limiter)
- PLAYHEADS:
- indicating where the track is "beating"
- blank=no beat and black-to-red where redder implies greater env~ rms
- MODULAE:
- for information only to show the relative values of the selected modulators
- WEIGHTS:
- sent to [list-wrandom] when randomizing the When, Accent, and Offset modulators
- to use click READ_ARRAYS, adjust as desired, click WRITE, uncheck READ ARRAYS
- EVEN=unweighted, RND for random, and 0-7 for preset shapes
- PRESETS:
- ...self explanatory
-
PER TRACK ACCORDION:
- 8 sections, 1 per track
- each open-closable with the left most bang/track
- opening one track closes the previously opened track
- includes main (always shown)
- with knobs for the sample (with 300ms debounce)
- knobs for the modulators (When, Accent, and Offset) [1..16]
- toggles if you want that parameter to be randomized after X bars
- and when opened, 5 optional effects
- adsr, vcf, delayfb, distortion, and reverb
- D-W=dry-wet
- 2 parameters per effect
-
ALL:
when ON. sets the values for all of the tracks to the same value; reverts to the original values when turned OFF
MIDI:
CC 7=MASTER VOLUME
The other controls exposed to midi are the first four knobs of the accordion/main-gui. In other words, the Sample, When, Accent, and Offset knobs of each track. And the MUTE and SOLO of each track.
Control is based on a midimap file (./midimaps/midimap-default.txt).
So if it is easier to just edit that file to your controller, then just make a backup of it and edit as you need. In other words, midi-learn and changing midimap files is not supported.
The default midimap is:
By track
CCs
---TRACK--- | ---SAMPLE--- | ---WHEN--- | ---ACCENT--- | --- OFFSET--- |
---|---|---|---|---|
0 | 16 | 17 | 18 | 19 |
1 | 20 | 21 | 22 | 23 |
2 | 24 | 25 | 26 | 27 |
3 | 28 | 29 | 30 | 31 |
4 | 46 | 47 | 48 | 49 |
5 | 50 | 51 | 52 | 53 |
6 | 54 | 55 | 56 | 57 |
7 | 58 | 59 | 60 | 61 |
NOTEs
---TRACK--- | ---MUTE--- | ---SOLO--- |
---|---|---|
0 | 1 | 3 |
1 | 4 | 6 |
2 | 7 | 9 |
3 | 10 | 12 |
4 | 13 | 15 |
5 | 16 | 18 |
6 | 19 | 21 |
7 | 22 | 24 |
SAMPLES:
Ganymede looks for samples in its ./samples directory by subdirectory.
It generates a tof/pmenu from the directories in ./samples.
Once a directory is selected, it then searches for ./**/.wav (wavs within 1-deep subdirectories) and then ./*.wav (wavs within that main "kit" directory).
I have uploaded my collection of samples (that I gathered from https://archive.org/details/old-school-sample-cds-collection-01, Attribution-Non Commercial-Share Alike 4.0 International Creative Commons License, 90's Old School Sample CDs Collection by CyberYoukai) to the following link on my Google Drive:
https://drive.google.com/file/d/1SQmrLqhACOXXSmaEf0Iz-PiO7kTkYzO0/view?usp=sharing
It is a large 617 Mb .7z file, including two directories: by-instrument with 141 instruments and by-kit with 135 kits. The file names and directory structure have all been laid out according to Ganymede's needs, ex. no spaces, etc.
My suggestion to you is unpack the file into your Path so they are also available for all of your other patches.
MAKING KITS:
I found Kits are best made by adding directories in a "custom-kits" folder to your sampls directory and just adding files, but most especially shortcuts/symlinks to all the files or directories you want to include in the kit into that folder, ex. in a "bongs&congs" folder add shortcuts to those instument folders. Then, create a symnlink to "bongs&congs" in your ganymede/samples directory.
Note: if you want to experiment with kits on-the-fly (while the patch is on) just remember to click the REFRESH bang to get a new tof/pmenu of available kits from your latest ./samples directory.
If you want more freedom than a dynamic menu, you can use the OPEN_IND(depedent)_DIR bang to open any folder. But do bear in mind, Ganymede may not see all the wavs in that folder.
AFTERWARD/NOTES
-
the [hcs/folder_list] [tof/pmenu] can only hold (the first) 64 directories in the ./samples directory
-
the use of 1/16th notes (counter-interval) is completely arbitrary. However, that value (in the [pd global_metro] subpatch...at the noted hradio) is exposed and I will probably incorporate being able to change it in a future version)
-
rem: one of the beauties of this technique is: If you don't like the beat,rhythm, etc., you need only click ALL to get an entirely new beat or any of the other randomizers to re-randomize it OR let if do that by itself on AUTO until you like it, then just take it off AUTO.
-
One fun thing to do, is let it morph, with some set of toggles and bars selected, and just keep an ear out for the Really choice ones and record those or step in to "play" it, i.e. tweak the effects and parameters. It throws...rolls...a lot of them.
-
Another thing to play around with is the notion of Limited (bumpy) or Infinite(flat) sequences in conjunction with the number of bars. Since when and where the modulator triggers is contegent on when it resets.
-
Designed, as I said before, to be played, esp. once it gets rolling, it allows you to focus on the production (instead of writing beats) by controlling the ALL and Individual effects and parameters.
-
Note: if you really like the beat Don't forget to turn off the randomizers. CLEAR for instance works well. However you can't get the back the toggle values after they're cleared. (possible feature in next version)
-
The default.txt preset loads on loadbang. So if you want to save your state, then just click PRESETS>SAVE.
-
[folder_list] throws error messages if it can't find things, ex. when you're not using subdirectories in your kit. No need to worry about it. It just does that.
POSTSCRIPT
If you need any help, more explanation, advise, or have opinions or insight as to how I can make it better, I would love to hear from you.
I think that's >=95% of what I need to tell you.
If I think of anything else, I'll add it below.
Peace thru Music.
Love thru Pure Data.
-s
,
ffplay~ - An implementation of FFmpeg for audio playback of almost any media format
An implementation of FFmpeg for audio playback of almost any media format
When building, the FFmpeg libraries are dynamically linked by default, which means that you'll need a local installation of these libraries in order for the external to work.
Includes the following features:
-
play/pause and seek functionality.
-
changing the speed of playback.
-
reading and iterating through m3u playlists.
-
It reads pseudo m3u playlists. Each line in the m3u should be just the file name, preceded by a path relative to the location of the m3u if they don't reside in the same folder.
-
The m3u reader can also read nested m3u's. For example, an m3u could consist of the following three lines:
disc1.m3u disc2.m3u disc3.m3u
-
-
opening files from http urls.
-
retrieving metadata.
Creation args
- numeric list
-
The channel layout. Defaults to stereo if no args given.
-
Numbers specified represent the bits of an audio channel bit-mask. A full list of available channels can be found here: https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/channel_layout.h
-
Inlets
-
bang - Play/pause the currently loaded track.
- Sends a 1 or 0 through the last outlet to indicate whether it's playing or paused.
float - (Re)start playback of a given track number
- Zero will stop playback.
anything - Look for matching metadata
- If metadata is found, it will be sent through the right-most outlet.
- A file must be successfully opened for any of the above to work
- signal - Change the playback speed.
-
speed can be a factor between 16 and 1/16th.
-
speed can also be altered by sending the message [ speed $1 ( to the 1st inlet.
-
Outlets
-
signal - Left channel
-
signal - Right channel
- The number of signal outlets there are depends on the number of creation args given, with the default being 2 signals for stereo.
-
list - Outputs various messages including information regarding whether a file was successfully opened, whether a track is currently playing, track metadata, etc.
Messages
-
[ print $.. ( or [ info $.. ( - Prints metadata info.
-
If no args given, it will print general info. Otherwise, it will print custom info.
-
metadata needs to be surrounded with percent signs.
- Example [ print %artist% - %title% (
-
-
[ send $.. ( - Sends metadata info through the
last outlet. -
[ open $1 ( - Attempts to open a file.
- Sends a 1 or 0 through the last outlet to indicate success or failure.
-
[ seek $1 ( - Seek to a track position.
-
[ speed $1 ( - Set the playback speed.
-
[ play $1 ( - Set playback state to either playing or paused.
- Acts as a toggle when no args are given.
- When an arg is given, state is forced to playing(1) or paused(0).
-
[ interp $1 ( - Change the interpolation algorithm.
- Options include:
- Sinc (good | medium | fast)
- Zero-order hold
- Linear (the default)
- Options include:
-
[ stop ( - An alias for [ 0 (.
-
[ pos ( - Returns the track position.
-
Any unrecognized message is assumed to be a metadata term. If there is a match, the metadata will be sent through the last outlet.
Update - March 16 2022:
ffplay~ now uses Secret Rabbit Code for resampling, which makes playback speed transitions much smoother. Playback speed can also be manipulated with signals via the 2nd inlet.
ffplay~ is now available through deken. It is part of a larger library called quilt. Searching either "quilt" or "ffplay~" should give a result.
The FFmpeg libraries are still separate, but can be either easily downloaded or easily installed via a package manager.
For Windows users, the FFmpeg libraries can be downloaded here: https://github.com/myQwil/pd-quilt/releases/download/v0.7.7/ffmpeg.v4.4.1.Windows-amd64-32.zip.
For Linux and macOS users, A README file is included, which lists the dependencies for those platforms.