Old 10-06-2019, 06:14 AM   #1
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,514
Default Lua: Track navigator

Here's a brand new script (a very early version) if someone wants to test it - Download: https://stash.reaper.fm/37265/spk77%...0Navigator.zip

Select a track and when the mouse is on waveform display, press...
  • Left mouse button to play/stop
  • Right mouse button to navigate

spk77 is offline   Reply With Quote
Old 10-06-2019, 10:37 AM   #2
Broojacker
Human being with feelings
 
Join Date: Apr 2016
Posts: 23
Default

Very interesting idea, thanks!
__________________
soundcloud
Broojacker is offline   Reply With Quote
Old 10-06-2019, 10:52 AM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,030
Default

Looks good,

Very close to the base of my own track viewer, which has some fancy feature like spectral peaks and child track display and alignement with arrange view.

EDIT: The main difference is that your script works on the whole track length. A bit like the Navigator window. So a very different usage case. Cool !





Also, your version seems to have some interactivity.


Have you suceed to display multichannel waveform ?

Last edited by X-Raym; 10-06-2019 at 11:11 AM.
X-Raym is offline   Reply With Quote
Old 10-06-2019, 11:46 AM   #4
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,514
Default

Quote:
Originally Posted by Broojacker View Post
Very interesting idea, thanks!
Thanks!

Quote:
Originally Posted by X-Raym View Post
Looks good,

Very close to the base of my own track viewer, which has some fancy feature like spectral peaks and child track display and alignement with arrange view.



But nice your version has interactivity.


Have you suceed to display multichannel waveform ?
Thank you!


This function returns peak samples from all channels, but I'm not sure how the peak sample data is "packed":

Code:
integer reaper.GetMediaItemTake_Peaks(MediaItem_Take take, number peakrate, number starttime, integer numchannels, integer numsamplesperchannel, integer want_extra_type, reaper.array buf)

Gets block of peak samples to buf. Note that the peak samples are interleaved, but in two or three blocks (maximums, then minimums, then extra). Return value has 20 bits of returned sample count, then 4 bits of output_mode (0xf00000), then a bit to signify whether extra_type was available (0x1000000). extra_type can be 115 ('s') for spectral information, which will return peak samples as integers with the low 15 bits frequency, next 14 bits tonality.

Quote:
Originally Posted by X-Raym View Post

EDIT: The main difference is that your script works on the whole track length. A bit like the Navigator window. So a very different usage case. Cool !
That's right - it always zooms to all items on a track.
I'm always lost in projects on high zoom levels and I hope this will help me a little bit

Last edited by spk77; 10-06-2019 at 11:56 AM.
spk77 is offline   Reply With Quote
Old 10-07-2019, 06:42 AM   #5
Ivannn Bennnettt
Human being with feelings
 
Join Date: Feb 2017
Posts: 275
Default

Thank you for sharing!
Will it be on Reapack?
Ivannn Bennnettt is online now   Reply With Quote
Old 10-07-2019, 06:52 AM   #6
Ivannn Bennnettt
Human being with feelings
 
Join Date: Feb 2017
Posts: 275
Default

Quote:
Originally Posted by X-Raym View Post
Very close to the base of my own track viewer, which has some fancy feature like spectral peaks and child track display and alignement with arrange view.

EDIT: The main difference is that your script works on the whole track length. A bit like the Navigator window. So a very different usage case. Cool !
The mainest difference is your script isn't free
Ivannn Bennnettt is online now   Reply With Quote
Old 10-07-2019, 07:11 AM   #7
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,514
Default

Quote:
Originally Posted by Ivannn Bennnettt View Post
Thank you for sharing!
Will it be on Reapack?
Thanks! It will be on Reapack, but first I'll try to add some more features:
  • Show take names
  • Store data (dock state etc.)
  • Multichannel support
  • Ability to "lock" to tracks
  • Support for MIDI take data (currently it shows MIDI items as rectangles but MIDI notes/CCs etc. are not drawn)
  • Extra playcursor or playhead marker (don't know what it should be called...pressing spacebar would play from this playhead marker instead of the edit cursor)
spk77 is offline   Reply With Quote
Old 10-07-2019, 08:03 AM   #8
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 742
Default

Always such impressive work!!

Thanks so much to your contributions to the community! This looks very cool!
__________________
Cheers,
Andrew K
v5.982/64 Mac 10.12.+, i7 Quad 2.9GHz, 24GB
Thonex is offline   Reply With Quote
Old 10-07-2019, 08:05 AM   #9
Ivannn Bennnettt
Human being with feelings
 
Join Date: Feb 2017
Posts: 275
Default

Looking forward!
Ivannn Bennnettt is online now   Reply With Quote
Old 10-08-2019, 07:31 AM   #10
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,030
Default

Multichannel support ? Cant wait for the updated code so I can see the magic behind :P
X-Raym is offline   Reply With Quote
Old 10-09-2019, 06:31 AM   #11
Vagelis
Human being with feelings
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 310
Default

Thanks a lot! Looks very useful, with pleasure to test it
Vagelis is offline   Reply With Quote
Old 10-09-2019, 07:04 AM   #12
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,514
Default

Quote:
Originally Posted by Thonex View Post
Always such impressive work!!

Thanks so much to your contributions to the community! This looks very cool!
Thanks, I hope it'll be useful!

Quote:
Originally Posted by X-Raym View Post
Multichannel support ? Cant wait for the updated code so I can see the magic behind :P
Here's something I have figured out so far:

Looking at this function...
reaper.GetMediaItemTake_Peaks(take, peakrate, pos, n_chans, n_spls, want_extra_type, buf)


The data structure in "buf" looks like this:

If n_spls = 1, n_chans = 2:
ch1 max - sample 1
ch2 max - sample 1
ch1 min- sample 1
ch2 min - sample 1
ch1 spectral info - sample 1
ch2 spectral info - sample 1


If n_spls = 2, n_chans = 2:
ch1 max - sample 1
ch2 max - sample 1
ch1 max - sample 2
ch2 max - sample 2

ch1 min - sample 1
ch2 min - sample 1
ch1 min - sample 2
ch2 min - sample 2

ch1 spectral info - sample 1
ch2 spectral info - sample 1
ch1 spectral info - sample 2
ch2 spectral info - sample 2


So the order is:
  • First - Max peaks from each channel
  • Second - Min peaks from each channel
  • Third - Spectral info from each channel



Quote:
Originally Posted by Vagelis View Post
Thanks a lot! Looks very useful, with pleasure to test it
Thanks!
spk77 is offline   Reply With Quote
Old 10-09-2019, 07:46 AM   #13
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,030
Default

@spk77
Damn, that is some interlacing data !


Thx for the infos, I'll see what can do with that,
Though it is easy to be confused with such things ^^


Maybe I'll first experiment by splitting these data into other arrays.
X-Raym is offline   Reply With Quote
Old 10-09-2019, 02:12 PM   #14
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,030
Default

@spk77
It was hard. it was confusing.


But thx to your indications,


I finally succeed





Nice !

Last edited by X-Raym; 10-09-2019 at 03:23 PM.
X-Raym is offline   Reply With Quote
Old 10-09-2019, 02:21 PM   #15
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,514
Default

@X-Raym
Very nice!
I'm almost there (yes, it was surprisingly difficult ), I'll continue tomorrow.
spk77 is offline   Reply With Quote
Old 10-09-2019, 03:41 PM   #16
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,030
Default

@spk77
Take this code instead.... It has Spectral peaks and now multichannel support :P


I just updated it for you :P


https://github.com/ReaTeam/ReaScript...orm%20demo.lua


(this was the spectral peaks exploration thread : https://forum.cockos.com/showthread....35#post2190435 )



Note that the basis of what you are trying to achieve (display whole track length) would be only few line of code different than one of my waveform scripts,
So I may add add this feature to mine too


My script already has all the goodies (save dock, color track support, zooming etc...). According to your plan, it just don't have MIDI items support.
X-Raym is offline   Reply With Quote
Old 10-10-2019, 10:16 AM   #17
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,514
Default

Thanks X-Raym!
Looks like we are getting the peaks very much the same way:

Code:
  if spl_cnt > 0 then
    for i = 1, n_chans do
      peaks[i] = {} -- create a table for each channel
    end
    local s = 0 -- table size counter
    for pos = 1, n_spls*n_chans, n_chans do -- move bufferpos to start of next max peak
      -- loop through channels
      for i = 1, n_chans do
        local p = peaks[i]
        p[s+1] = buf[pos+i-1]                   -- max peak
        p[s+2] = buf[pos+n_chans*n_spls+i-1]    -- min peak
      end 
      s = s + 2
    end
  end

I think I'll keep this script as simple as possible (no spectral peaks or zooming etc.). I'll try to optimize it for its original purpose (it's a track navigator )
Also, this way our scripts don't overlap too much

Last edited by spk77; 10-10-2019 at 11:49 AM.
spk77 is offline   Reply With Quote
Old 10-10-2019, 10:20 AM   #18
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,030
Default

Indeed, very close code !


Main difference is that you use a table length variable, which is a bit more efficient than table.insert.


Quote:
I think I'll keep this script as simple as possible
That's why I originally thought with my script but you may have real fun scripting with waveform : it opens a lot of possibilities :P
X-Raym is offline   Reply With Quote
Old 10-10-2019, 10:47 AM   #19
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,514
Default

Quote:
Originally Posted by X-Raym View Post
That's why I originally thought with my script but you may have real fun scripting with waveform : it opens a lot of possibilities :P
That's right - and coding should be fun
spk77 is offline   Reply With Quote
Old 10-11-2019, 06:23 AM   #20
X-Tech
Human being with feelings
 
Join Date: Apr 2015
Posts: 492
Default

representing tracks like this but when folder is selected or bus to represent track in bus or in folder oh yes...
__________________
nonononononono
X-Tech is offline   Reply With Quote
Old 10-11-2019, 10:05 AM   #21
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 143
Default

Quote:
Originally Posted by X-Tech View Post
representing tracks like this but when folder is selected or bus to represent track in bus or in folder oh yes...
+1

This script seems pretty awesome. I'm just about to install
Dafarkias is offline   Reply With Quote
Old 10-11-2019, 12:49 PM   #22
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,514
Default

Thanks!

I'm going to post a new version tomorrow:

These things are implemented:
  • show take name
  • multichannel support

spk77 is offline   Reply With Quote
Old 10-12-2019, 12:15 AM   #23
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 143
Default

The ability to un/lock the track navigator to a specific track would be very nice. For editing drums, for instance, or etc..
Dafarkias is offline   Reply With Quote
Old 10-12-2019, 02:58 AM   #24
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,030
Default

@spk77
How do you plan to handle multi track selection (or parent track) ?
Displaying all the waveform one over the other (like in my script) or one under ther other ? (like multichannel).

@Dafarkias
Sure it is must have functions. That's my versions already support that :P And also parent tracks.

Last edited by X-Raym; 10-12-2019 at 03:04 AM.
X-Raym is offline   Reply With Quote
Old 10-12-2019, 03:58 AM   #25
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 143
Default

Quote:
Originally Posted by X-Raym View Post
@Dafarkias
Sure it is must have functions. That's my versions already support that :P And also parent tracks.
Your script seems nice! Offer me a generous discount and I may just purchase :P

I could probably alter spk's script to include track-locking, but before I would do such a thing, there is no harm in waiting a few days/weeks to see if spk incorporates this feature into the script..
Dafarkias is offline   Reply With Quote
Old 10-12-2019, 05:22 AM   #26
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,514
Default

Quote:
Originally Posted by X-Raym View Post
@spk77
How do you plan to handle multi track selection (or parent track) ?
Displaying all the waveform one over the other (like in my script) or one under ther other ? (like multichannel).
No plans for multitrack viewer at the moment, but probably tracks would be shown as they are shown in the reaper's project navigator. When I get the locking system implemented, it will be possible to open multiple script windows and lock each one to different tracks.

@Dafarkias
Locking feature will be implemented soon. I haven't decided yet where it should be enabled from: right click menu? button? I would like to keep the waveform display uncluttered...


This old script has a right click menu (with a track list)...I might do it like that maybe.
spk77 is offline   Reply With Quote
Old 10-12-2019, 06:07 AM   #27
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 143
Default

Quote:
Originally Posted by spk77 View Post
@Dafarkias
Locking feature will be implemented soon. I haven't decided yet where it should be enabled from: right click menu? button? I would like to keep the waveform display uncluttered...
Just for fun I made a few personal alterations to your script (your coding is very clean, by the way):
  • automatic keyboard focus when mouse hovers over script window (via JS Extensions)
  • 'L' key locks a track and inserts text at the top of GUI stating which track was locked
  • script remembers docking via get/setextstate
  • script draws both play cursor and edit cursor in GUI
  • left-click centers arrange via reaper.GetSet_ArrangeView2
  • enabled mouse_wheel vertical scrolling while left-click centering
  • right-click plays from clicked location or stops playback (if already playing)
  • 'C' toggles colorization of waveform from 'white' to selected navigation track's color
  • script shows project markers

To do:
-add toggle setting: 'always show full project length' (regardless of item-positions in track[s])
-allow 'locking' of multiple tracks
-display child-tracks of selected/locked tracks

Last edited by Dafarkias; Yesterday at 02:06 AM.
Dafarkias is offline   Reply With Quote
Old Yesterday, 01:29 PM   #28
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,514
Default

@Dafarkias
Very nice! You are really fast
Feel free to post your versions here.

I re-organized the code (mostly mouse related stuff) - still have to do some cleaning before I post it here (or reapack), but here's how it looks at the moment:

New features:
  • Locking from menu
  • Hold lmb to play from cursor - stop on release (I like this. It will be the default behavior.)
spk77 is offline   Reply With Quote
Old Yesterday, 11:21 PM   #29
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 143
Default

Quote:
Originally Posted by spk77 View Post
@Dafarkias
Very nice! You are really fast
Feel free to post your versions here.
You know when they say, slow and steady wins the race :P I know that I'm an amateur coder, your coding is much cleaner that mine, much more efficient and readable. I just code for raw functionality and enjoyment (sometimes it's frustrating though lol).

I would like to post the script here, just in case you are interested in testing how I employed the lmb and rmb in the script--it's pretty unique--you may like it, you may not!

I think I'm actually going to stop my planned alterations on your script because your script had inspired me to work on a similar type of script: a project overview map.

Fundamental features (concept):

-Shows anatomically correct layout of entire project in script window
-script window is scalable
-quickly scroll to precise 'map' location
-zoom to specific location via 'map' area selection
-move edit/play cursor via map
-interactive features with project markers

(I'm not trying to derail your thread. Please tell me if I'm bothering you with my posts here)
Dafarkias is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.