everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
 Warning: Initial query:
 %22dtas-mlib: add dump support for debugging%22
 returned no results, used:
 "dtas-mlib: add dump support for debugging"
 instead

Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [ANN] dtas 0.12.0 - duct tape audio suite for *nix
@ 2015-12-14  4:03  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-12-14  4:03 UTC (permalink / raw)
  To: ruby-talk; +Cc: dtas-all

Free Software command-line tools for audio playback, mastering, and
whatever else related to audio.  dtas follows the worse-is-better
philosophy and acts as duct tape to combine existing command-line tools
for flexibility and ease-of-development.  dtas is currently implemented
in Ruby (and some embedded shell), but may use other languages in the
future.

Changes: dtas 0.12.0 - many player updates

Notable additions for dtas-player music listeners.

  dtas-ctl queue cat - display the internal queue
  dtas-tl shuffle [true|false] - toggle tracklist shuffle
  dtas-tl edit - open tracklist in an editor
                 see dtas-tl(1) manpage for more details on this:
                 http://dtas.80x24.org/dtas-tl.txt

The player tracklist now uses sequential track IDs instead of Ruby
object IDs, so it should be easier to use existing commands such as
"dtas-tl goto" and "dtas-tl remove"

For people using dtas-player for applying real-time effects to
splitfx YAML files, dtas-player can now watch for changes in scripts
specified in the "command" field of the splitfx YAML file.
Previously, dtas-player could only read the splitfx YAML file
itself.  This requires GNU/Linux and the sleepy_penguin RubyGem
installed.

dtas-splitfx also learned some switches to allow easier
interoperability with other processing tools:

  -p/--sox-pipe - identical to the sox(1) option

  -t/--trim - only expose part of the track, useful when
              combined with the above -p switch

See http://dtas.80x24.org/dtas-splitfx.txt for more details.

There's also some work-in-progress stuff that's not well documented
at the moment.  As with anything pre-1.0, expect the possibility
of incompatible changes.

Since I'm not good at designing protocols, I've also started working
on mpd compatibility layer to allow using the normal music playback
stuff with more clients (some of the clients I actually like, unlike
the seemingly GUI-only landscape of MPRIS :P).

Of course, dtas-player itself has most the capabilities of a
Unix shell; and those capabilities will certainly not be available
to mpd or MPRIS clients.

64 changes since dtas 0.11.0
      INSTALL: update documentation for 0.11.0 release
      splitfx: fix lossy output with player command is in use
      splitfx: fix non-generic, user-specified targets
      use monotonic clock on Ruby 2.1+
      dtas-splitfx: no arguments for quiet and --no-dither
      dtas-splitfx: support --trim argument
      process: implement array expansion to preserve spaces
      splitfx: show correct command for output
      splitfx: remove support for encoding opus
      dtas-console: bind "o" to display time in absolute seconds
      splitfx: avoid double-truncation with user command
      source/splitfx: allow watching extra external scripts
      splitfx: drop unnecessary variable
      splitfx: documentation for subclasses
      splitfx: simplify output display
      dtas-splitfx: comment describing -j (nothing) as infinite
      dtas-*edit: fix inotify watch invocations
      splitfx: allow -p/--sox-pipe option
      splitfx: ensure rate is an integer
      splitfx: set OUTFMT correctly for subenv if command is set
      favor recv and recv_nonblock over recvmsg variants
      parse_time: pass through numeric types
      parse_freq: trivial new module for parsing frequencies
      use a common /dev/null
      player: add "queue cat" command
      dtas-readahead: new script for -player users on Linux
      dtas-readahead: avoid polling on pause
      dtas-cueedit: escape path to temporary file
      dtas-readahead: make executable
      gemspec: use SPDX-compatible license
      README: add link to NNTP and Atom feeds
      player: cleanup command dispatch
      dtas-archive: allow specifying SoX compression factor
      gemspec: duplicate frozen string for older Rubygems
      allow building the gem without pandoc
      introduce dtas-mlib for music library functions
      dtas-mlib: add dump support for debugging
      tracklist: use lower number unique track IDs
      tracklist: do not mutate @list when serializing
      tracklist: avoid needlessly building a hash for track IDs
      tracklist: shuffle support
      tracklist: support limiting maximum tracklist size
      player: refactor and document tracklist interface
      player: tl (repeat|shuffle|max) and trim swap values
      tracklist: fixup idempotent "tl shuffle false"
      switch to exception-free non-blocking I/O
      add .gitattributes for Ruby method detection
      mlib: remove non-existent entries
      mlib: add stats support
      mlib: no kwargs for 1.9.3 compatibility
      mlib: add find/search functionality based on mpd
      mlib: split out the output format from the library
      mlib: remove kwargs harder
      player: reduce I/O priority of connected clients
      mlib: SYSTEM_DEFAULT handlers for SIGINT and SIGPIPE
      player: support "tl clear" internally
      test_unixserver: remove test for element limit
      player: dump state file asynchronously when requested
      parse_time: enable frozen_string_literal
      unix_accepted: enable checking for readability after emit
      tracklist: swap functionality
      player: show "tracklist" hash with summary info with "current"
      dtas-tl: learn an "edit" sub command
      doc: document additions to tracklist handling

* homepage: http://dtas.80x24.org/README
* http://dtas.80x24.org/INSTALL
* http://dtas.80x24.org/dtas-player.txt
* http://dtas.80x24.org/NEWS
* git clone git://80x24.org/dtas
* dtas-all@nongnu.org (plain-text only, no HTML mail, please)
* mailing list archives http://80x24.org/dtas-all/

-- 
EW


^ permalink raw reply	[relevance 7%]

* [PATCH 2/1] dtas-mlib: add dump support for debugging
  @ 2015-11-28 11:16  5% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-11-28 11:16 UTC (permalink / raw)
  To: dtas-all

Using an RFC-822-like format since YAML quoting rules aren't very
human-friendly, and we already prevent newlines from entering our
DB anyways.
---
 bin/dtas-mlib    |  18 +++++---
 lib/dtas/mlib.rb | 134 +++++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 132 insertions(+), 20 deletions(-)

diff --git a/bin/dtas-mlib b/bin/dtas-mlib
index 0e17d91..6331808 100755
--- a/bin/dtas-mlib
+++ b/bin/dtas-mlib
@@ -1,7 +1,7 @@
 #!/usr/bin/env ruby
 # Copyright (C) 2015 all contributors <dtas-all@nongnu.org>
 # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
-usage = "#$0 [-d DATABASE-URI] ACTION [DIRECTORY]"
+usage = "#$0 [-d DATABASE-URI] ACTION [ARGS]"
 Thread.abort_on_exception = $stderr.sync = $stdout.sync = true
 require 'dtas/mlib'
 require 'optparse'
@@ -27,13 +27,19 @@ unless db.include?('://')
   end
 end
 
+def mlib(db, migrate: false)
+  m = DTAS::Mlib.new(db)
+  m.migrate if migrate
+  m
+end
+
 case action = ARGV.shift
-when 'update'
+when 'update', 'up'
   directory = ARGV.shift or abort "DIRECTORY required\n#{usage}"
+  mlib(db, migrate: true).update(directory)
+when 'dump' # mainly for debugging
+  directory = ARGV.shift || '/'
+  mlib(db).dump(directory)
 else
   abort usage
 end
-
-mlib = DTAS::Mlib.new(db)
-mlib.migrate
-mlib.__send__(action, directory)
diff --git a/lib/dtas/mlib.rb b/lib/dtas/mlib.rb
index 59a589c..9a112c9 100644
--- a/lib/dtas/mlib.rb
+++ b/lib/dtas/mlib.rb
@@ -11,6 +11,7 @@ class DTAS::Mlib
   attr_accessor :follow_outside_symlinks
   attr_accessor :follow_inside_symlinks
   attr_accessor :tags
+
   DM_DIR = -1
   DM_IGN = -2
   include DTAS::Process
@@ -240,6 +241,10 @@ class DTAS::Mlib
     node[:id] = node_id
   end
 
+  def node_lookup(parent_id, name)
+    @db[:nodes][name: name, parent_id: parent_id]
+  end
+
   def node_ensure(parent_id, name, tlen, ctime = nil)
     q = { name: name, parent_id: parent_id }
     if node = @db[:nodes][q]
@@ -254,28 +259,33 @@ class DTAS::Mlib
     node
   end
 
-  def scan_dir(path, st, parent_id = nil)
+  def cd(path)
     prev_wd = @pwd
     Dir.chdir(path)
     cur = @pwd = Dir.pwd.b
-
-    # TODO: use parent_id if given
-    dir = dir_vivify(cur.split(%r{/+}n), st.ctime.to_i)
-    Dir.foreach('.', encoding: Encoding::BINARY) do |x|
-      case x
-      when '.', '..', %r{\n}n
-        # files with newlines in them are rare and last I checked (in 2008),
-        # mpd could not support them, either.  So lets not bother for now.
-        next
-      else
-        scan_any(x, dir[:id])
-      end
-    end
+    yield
   ensure
     Dir.chdir(prev_wd) if cur && prev_wd
     @pwd = prev_wd
   end
 
+  def scan_dir(path, st, parent_id = nil)
+    cd(path) do
+      # TODO: use parent_id if given
+      dir = dir_vivify(@pwd.split(%r{/+}n), st.ctime.to_i)
+      Dir.foreach('.', encoding: Encoding::BINARY) do |x|
+        case x
+        when '.', '..', %r{\n}n
+          # files with newlines in them are rare and last I checked (in 2008),
+          # mpd could not support them, either.  So lets not bother for now.
+          next
+        else
+          scan_any(x, dir[:id])
+        end
+      end
+    end
+  end
+
   def send_harder(sock, msg)
     sock.sendmsg(msg)
   rescue Errno::EMSGSIZE
@@ -287,4 +297,100 @@ class DTAS::Mlib
       warn "#{msg.bytesize} too big, dropped #{e.class}"
     end
   end
+
+  def find_dump_part(cur, base)
+    parts = @pwd.split(%r{/+}n)
+    parts.shift # no first part
+    parts << base if base
+    parts.each do |name|
+      if cur = node_lookup(cur[:id], name)
+        case cur[:tlen]
+        when DM_DIR then next # keep going
+        when DM_IGN then return [ :ignored, cur ]
+        else # regular audio
+          return cur if name.object_id == parts[-1].object_id
+          return [ :notdir, cur ]
+        end
+      else
+        return [ :missing, name ]
+      end
+    end
+    cur
+  end
+
+  # returns an array on error
+  def dump(path)
+    dir = path
+    base = nil
+    retried = false
+    begin
+      found = cd(dir) { find_dump_part(root_node, base) }
+    rescue Errno::ENOTDIR
+      raise if retried || found
+      dir, base = File.split(path)
+      retried = true
+      retry
+    end
+    return found if Array === found # error
+
+    # success
+    load_tags
+    require 'yaml'
+    @tag_rmap = @tag_map.invert
+    if found[:tlen] == DM_DIR
+      emit_recurse(found)
+    else
+      parent = @db[:nodes][id: found[:parent_id]]
+      parent or abort "missing parent for #{found.inspect}"
+      parent[:dirname] ||= path_of(parent)
+      emit_1(found, parent)
+    end
+  end
+
+  def path_of(node)
+    return '/' if node[:name] == ''
+    parts = [ node[:name], '' ]
+    begin
+      node = @db[:nodes][id: node[:parent_id]]
+      break if node[:id] == node[:parent_id]
+      parts.unshift node[:name]
+    end while true
+    parts.unshift('')
+    parts.join('/')
+  end
+
+  def emit_recurse(node)
+    node[:dirname] ||= path_of(node)
+    @db[:nodes].where(parent_id: node[:id]).order(:name).each do |nd|
+      next if nd[:id] == node[:id] # root_node
+      case nd[:tlen]
+      when DM_DIR then emit_recurse(nd)
+      when DM_IGN then next
+      else
+        emit_1(nd, node)
+      end
+    end
+  end
+
+  def emit_1(node, parent)
+    comments = Hash.new { |h,k| h[k] = [] }
+    @db['SELECT c.tag_id, v.val FROM comments c ' \
+        'LEFT JOIN vals v ON v.id = c.val_id ' \
+        "WHERE c.node_id = #{node[:id]} ORDER BY c.tag_id"].map do |c|
+      comments[@tag_rmap[c[:tag_id]]] << c[:val]
+    end
+    puts "Path: #{parent[:dirname]}#{node[:name]}"
+    puts "Length: #{node[:tlen]}"
+    return if comments.empty?
+    puts 'Comments:'
+    comments.each do |k,v|
+      if v.size == 1
+        puts "\t#{k}: #{v[0]}"
+      else
+        v << ''
+        puts "\t#{k}:\n\t\t#{v.join("\t\t\n")}"
+      end
+    end
+    puts
+  end
 end
-- 
EW



^ permalink raw reply related	[relevance 5%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-11-27 11:50     [PATCH] introduce dtas-mlib for music library functions Eric Wong
2015-11-28 11:16  5% ` [PATCH 2/1] dtas-mlib: add dump support for debugging Eric Wong
2015-12-14  4:03  7% [ANN] dtas 0.12.0 - duct tape audio suite for *nix Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/dtas.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).