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
85 changes: 64 additions & 21 deletions Tools/com.renoise.Sononymph.xrnx/App.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,28 @@ function App:check_paths()

local path = self.prefs.path_to_config.value
local success,err = App.check_path(path)
if not success then
-- The stored query.json is gone. This happens every time Sononym updates
-- itself, because the configuration lives in a version-named folder:
-- .../Sononym/1.6.2/query.json becomes .../Sononym/1.6.14/query.json
-- Adopt the newest detected version instead of only reporting "invalid paths".
if not self._healing_config_path then
self._healing_config_path = true
local versions = App.find_sononym_versions()
local newest = versions and versions[1]
if newest and (newest.path ~= path) then
LOG("check_paths: stored ConfigPath is gone ("..tostring(path)
..") - switching to detected Sononym "..newest.version..": "..newest.path)
self.prefs.path_to_config.value = cFilesystem.unixslashes(newest.path)
path = self.prefs.path_to_config.value
success,err = App.check_path(path)
if success then
renoise.app():show_status("Sononymph: ConfigPath updated to Sononym "..newest.version)
end
end
self._healing_config_path = false
end
end
if not success then
self.invalid_path_observable.value = path
self.paths_are_valid_observable.value = false
Expand Down Expand Up @@ -752,16 +774,17 @@ function App:do_search()
return false,"Unable to Launch Search: " .. err
end

local path_to_exe=cFilesystem.unixslashes(self.prefs.path_to_exe.value)
local tmp_path=cFilesystem.unixslashes(tmp_path)


local path_to_exe = cFilesystem.unixslashes(self.prefs.path_to_exe.value)
local cmd = string.format('"%s" %s',path_to_exe,cFilesystem.unixslashes(tmp_path))
print (cmd)
local code = os.execute(cmd .. " &")
tmp_path = cFilesystem.unixslashes(tmp_path)

return true
-- quote both arguments: the temp folder and/or the user folder can contain
-- spaces. the file argument needs native separators, or Sononym reports
-- "Indexing error - Unable to resolve location" on Windows.
local cmd = string.format('"%s" "%s"',path_to_exe,App.native_path(tmp_path))
LOG("do_search:",cmd)
os.execute(cmd .. " &")

return true
end

---------------------------------------------------------------------------------------------------
Expand All @@ -782,7 +805,8 @@ function App:do_browse()
end

local path_to_exe = cFilesystem.unixslashes(self.prefs.path_to_exe.value)
local browse_path = cFilesystem.unixslashes(folder_path)
-- native separators: Sononym's crawler cannot resolve "C:/..." on Windows
local browse_path = App.native_path(cFilesystem.unixslashes(folder_path))

-- Launch Sononym with the folder path to enter browse mode
local cmd = string.format('"%s" "%s"', path_to_exe, browse_path)
Expand Down Expand Up @@ -1244,6 +1268,23 @@ function App.parse_config(path)

end

---------------------------------------------------------------------------------------------------
-- Convert a path to the separator style the host OS expects.
-- Paths are kept internally in unix style (cFilesystem.unixslashes), but
-- Sononym's crawler on Windows cannot resolve "C:/Users/.../file.flac" and
-- answers with "Indexing error - Unable to resolve location". Any path handed
-- to the Sononym executable as an argument has to use native separators.
-- @param file_path (string)
-- @return string

function App.native_path(file_path)
if not file_path then return file_path end
if (os.platform() == "WINDOWS") then
return (string.gsub(file_path,"/","\\"))
end
return file_path
end

---------------------------------------------------------------------------------------------------
-- check if path is valid and existing
-- @return boolean
Expand Down Expand Up @@ -1522,20 +1563,22 @@ renoise.tool().preferences = prefs

function OpenConfigPath()

--print (prefs.path_to_config)
local config_path = renoise.tool().preferences.path_to_config.value
local directory_path = config_path:match("(.*/)")
oprint(os.platform())
oprint(directory_path)
oprint(config_path)
local command
local os_name = os.platform()
local config_path = renoise.tool().preferences.path_to_config.value

if not config_path or (config_path == "") then
renoise.app():show_status("Sononymph: no ConfigPath is set yet - use Detect or Browse first.")
return
end

if os_name == "WINDOWS" then command = 'start "" "' .. directory_path .. '"'
elseif os_name == "MACINTOSH" then command = 'open "' .. directory_path .. '"'
else os_name = 'xdg-open "' .. directory_path .. '"' end
os.execute(command .. " &")
-- accept both unix and windows separators: the path can be typed in by hand
local directory_path = config_path:match("(.*[/\\])")
if not directory_path or not io.exists(directory_path) then
renoise.app():show_status("Sononymph: the ConfigPath folder does not exist: "..config_path)
return
end

LOG("OpenConfigPath:",directory_path)
renoise.app():open_path(directory_path)

end

Expand Down
25 changes: 20 additions & 5 deletions Tools/com.renoise.Sononymph.xrnx/AppUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -420,21 +420,36 @@ function AppUI:create_dialog()
renoise.app():show_warning(err or "Failed to set ConfigPath")
end
else
-- Multiple versions found - show dropdown for selection
-- Multiple versions found - apply the newest one right away and
-- offer the dropdown in case an older one is wanted.
-- Do NOT rely on the popup notifier to apply the first entry:
-- a popup does not fire its notifier when the picked index is
-- already the current one, and the popup starts at index 1. So
-- picking "the newest" - the obvious choice - would silently
-- leave ConfigPath untouched and the tool stuck on "invalid paths".
self.config_paths = versions


local newest = versions[1]
local success, err = self.owner:set_path_to_config(newest.path)
if not success then
renoise.app():show_warning(err or "Failed to set ConfigPath")
end
vb.views["path_to_config"].text = newest.path

-- Build dropdown items
local dropdown_items = {}
for i, version_info in ipairs(versions) do
table.insert(dropdown_items, "Sononym " .. version_info.version .. " (" .. version_info.path .. ")")
end
-- Populate the popup menu

-- Populate the popup menu, pre-selecting the version just applied
vb.views["config_path_popup"].items = dropdown_items
vb.views["config_path_popup"].value = 1
-- Show the popup and hide the textfield
vb.views["config_path_popup"].visible = true
vb.views["path_to_config"].visible = false
renoise.app():show_status("Multiple versions found - please select one")
renoise.app():show_status("ConfigPath set to newest: " .. newest.path
.. " (" .. #versions .. " versions found - pick another from the list if needed)")
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions Tools/com.renoise.Sononymph.xrnx/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 1.11

### Fixes
- **Similarity search now works on Windows**: Sononym answered every search launched from Renoise with `Indexing error - Reason: Unable to resolve location`. The temporary sample file was passed with forward slashes (`C:/Users/.../Renoise_TmpFile.flac`), which Sononym's crawler cannot resolve. Arguments handed to the Sononym executable are now converted to native separators (`App.native_path()`); the same applies to Browse Folder in Sononym.
- **Quoted the search argument**: the temp file path was passed unquoted, so a user or temp folder containing a space broke the launch.
- **"Detect" applied nothing when several Sononym versions were installed**: with 2+ versions the button only populated the dropdown and relied on its notifier. A popup does not fire its notifier when the picked index is already the current one, and it starts at index 1 - so choosing the newest version, the obvious choice, silently left ConfigPath unset and the tool stuck on "invalid paths". Detect now applies the newest version immediately and keeps the dropdown for picking an older one.
- **"Open Path" crashed when ConfigPath was unset**: `App.lua:1521: attempt to concatenate local 'directory_path' (a nil value)`, which Renoise reports as the tool failing in one of its notifiers. Empty and non-matching paths are now reported in the status bar, and both unix and windows separators are accepted. The folder is now opened with `renoise.app():open_path()` instead of a hand-rolled per-platform shell command, which also fixes Linux, where the branch assigned its command to `os_name` instead of `command` and threw.
- **A Sononym update no longer breaks the configuration**: Sononym keeps `query.json` in a version-named folder, so `.../Sononym/1.6.2/query.json` becomes `.../Sononym/1.6.14/query.json` as soon as Sononym updates itself. The tool was left pointing at a file that no longer existed and simply reported "invalid paths". It now adopts the newest version it can find and says which one in the status bar.

## 1.10

### New Features
Expand Down
2 changes: 1 addition & 1 deletion Tools/com.renoise.Sononymph.xrnx/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ require ('App')
-- local variables & initialization
---------------------------------------------------------------------------------------------------
local TOOL_NAME = "Sononymph"
local TOOL_VERSION = "1.10"
local TOOL_VERSION = "1.11"

local prefs = AppPrefs()
renoise.tool().preferences = prefs
Expand Down
2 changes: 1 addition & 1 deletion Tools/com.renoise.Sononymph.xrnx/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<RenoiseScriptingTool doc_version="0">
<Name>Sononymph</Name>
<Id>com.renoise.Sononymph</Id>
<Version>1.10</Version>
<Version>1.11</Version>
<ApiVersion>6</ApiVersion>
<Author>danoise &amp; esaruoho</Author>
<AutoUpgraded>false</AutoUpgraded>
Expand Down