Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@ wavesync sync -p

When a source file's sample rate isn't supported by the target device, Wavesync selects the closest supported rate. Example: If a 96kHz file is synced to an Octatrack (which only supports 44.1kHz), it will be downsampled to 44.1kHz.

### Sets (experimental)
### Setlists (experimental)

A set is a named, ordered selection of tracks from your library. Sets are stored as YAML files inside a `.sets` folder within the library directory. Syncing sets to devices is not yet implemented.
A setlist is a named, ordered selection of tracks from your library. Setlists are stored as YAML files inside a `.setlists` folder within the library directory. Syncing setlists to devices is not yet implemented.

```bash
# Create a new set and open the interactive editor
wavesync set create NAME
# Create a new setlist and open the interactive editor
wavesync setlist create NAME

# Edit an existing set
wavesync set edit NAME
# Edit an existing setlist
wavesync setlist edit NAME

# List all sets
wavesync set list
# List all setlists
wavesync setlist list
```

## Development
Expand Down
4 changes: 2 additions & 2 deletions lib/wavesync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Wavesync
require 'wavesync/scanner'
require 'wavesync/bpm_detector'
require 'wavesync/analyzer'
require 'wavesync/set'
require 'wavesync/set_editor'
require 'wavesync/setlist'
require 'wavesync/setlist_editor'
require 'wavesync/commands'
require 'wavesync/cli'
4 changes: 2 additions & 2 deletions lib/wavesync/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def self.load_config(path)
require_relative 'commands/command'
require_relative 'commands/sync'
require_relative 'commands/analyze'
require_relative 'commands/set'
require_relative 'commands/setlist'
require_relative 'commands/help'

ALL = [Sync, Analyze, Set, Help].freeze
ALL = [Sync, Analyze, Setlist, Help].freeze
end
end
66 changes: 0 additions & 66 deletions lib/wavesync/commands/set.rb

This file was deleted.

66 changes: 66 additions & 0 deletions lib/wavesync/commands/setlist.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# frozen_string_literal: true
# rbs_inline: enabled

require 'optparse'

module Wavesync
module Commands
class Setlist < Command
self.name = 'setlist'
self.subcommands = [
Subcommand.new(usage: 'setlist create NAME', description: 'Create a new setlist'),
Subcommand.new(usage: 'setlist edit NAME', description: 'Edit an existing setlist'),
Subcommand.new(usage: 'setlist list', description: 'List all setlists')
].freeze

#: () -> void
def run
subcommand = ARGV.shift

_options, config = parse_options(banner: 'Usage: wavesync setlist <subcommand> [options]')

case subcommand
when 'create'
name = require_name('create')
if Wavesync::Setlist.exists?(config.library, name)
puts "Setlist '#{name}' already exists. Use 'wavesync setlist edit #{name}' to edit it."
exit 1
end
setlist = Wavesync::Setlist.new(config.library, name)
Wavesync::SetlistEditor.new(setlist, config.library).run
when 'edit'
name = require_name('edit')
unless Wavesync::Setlist.exists?(config.library, name)
puts "Setlist '#{name}' not found. Use 'wavesync setlist create #{name}' to create it."
exit 1
end
setlist = Wavesync::Setlist.load(config.library, name)
Wavesync::SetlistEditor.new(setlist, config.library).run
when 'list'
setlists = Wavesync::Setlist.all(config.library)
if setlists.empty?
puts 'No setlists found.'
else
setlists.each { |setlist| puts "#{setlist.name} (#{setlist.tracks.size} tracks)" }
end
else
puts "Unknown subcommand: #{subcommand || '(none)'}"
puts 'Available subcommands: create, edit, list'
exit 1
end
end

private

#: (String subcommand) -> String
def require_name(subcommand)
name = ARGV.shift
unless name
puts "Usage: wavesync setlist #{subcommand} <name>"
exit 1
end
name
end
end
end
end
26 changes: 13 additions & 13 deletions lib/wavesync/set.rb → lib/wavesync/setlist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@
require 'fileutils'

module Wavesync
class Set
SETS_FOLDER = '.sets'
class Setlist
SETLISTS_FOLDER = '.setlists'

attr_reader :name #: String
attr_reader :tracks #: Array[String]
attr_reader :library_path #: String

#: (String library_path) -> String
def self.sets_path(library_path)
File.join(library_path, SETS_FOLDER)
def self.setlists_path(library_path)
File.join(library_path, SETLISTS_FOLDER)
end

#: (String library_path, String name) -> String
def self.set_path(library_path, name)
File.join(sets_path(library_path), "#{name}.yml")
def self.setlist_path(library_path, name)
File.join(setlists_path(library_path), "#{name}.yml")
end

#: (String library_path, String name) -> Set
#: (String library_path, String name) -> Setlist
def self.load(library_path, name)
data = YAML.load_file(set_path(library_path, name))
data = YAML.load_file(setlist_path(library_path, name))
new(library_path, data['name'], expand_tracks(library_path, data['tracks']))
end

#: (String library_path) -> Array[Set]
#: (String library_path) -> Array[Setlist]
def self.all(library_path)
path = sets_path(library_path)
path = setlists_path(library_path)
return [] unless Dir.exist?(path)

Dir.glob(File.join(path, '*.yml')).map do |file|
Expand All @@ -41,7 +41,7 @@ def self.all(library_path)

#: (String library_path, String name) -> bool
def self.exists?(library_path, name)
File.exist?(set_path(library_path, name))
File.exist?(setlist_path(library_path, name))
end

#: (String library_path, String name, ?Array[String] tracks) -> void
Expand Down Expand Up @@ -77,8 +77,8 @@ def move_down(index)

#: () -> void
def save
FileUtils.mkdir_p(self.class.sets_path(@library_path))
File.write(self.class.set_path(@library_path, @name), to_yaml)
FileUtils.mkdir_p(self.class.setlists_path(@library_path))
File.write(self.class.setlist_path(@library_path, @name), to_yaml)
end

private
Expand Down
Loading
Loading