Author Topic: [Probably don't do this] How to put music outside the music folder  (Read 2258 times)

0 Members and 1 Guest are viewing this topic.

Offline Dullstar

  • Posts: 2092
    • View Profile
    • Leafwing Studios Website (EXTREMELY OUTDATED)
So I found out you can do a thing. I don't think it's intended, but technically it could be used as a feature. I'm not endorsing this technique, but I think it's best to go public about this discovery, and let the community and namida decide what, if any, response should be made to prevent it, rather than relying on obscurity to make sure people don't do it. Of course, if you know relative file paths, it's pretty trivial, but on the other hand you might simply not have thought to try this, because, well, you probably shouldn't actually do this.

Maybe this should have gone in the Bugs and Suggestions subforum instead, but I wasn't comfortable calling it a bug and also wasn't comfortable calling it a suggestion either. I guess I'm intending a discussion here? Still, mods: I won't be upset if you decide it should be moved there.



This is almost certainly bad practice and you probably shouldn't do it.


A recent post by WillLem led me to believe he'd encountered an issue with a music pack masking the default music and got me thinking about the way music filenames are handled and how name collisions can occur because of it. I wanted to think about ways the engine could help prevent these collisions (beyond just hoping pack authors adopt their own unique subfolders or naming conventions), and this made me think about whether we could allow level packs to store their music in their own fully self-contained music folders inside the pack, instead of part of a separate directory. I wrote up a huge post about it (along with some other methods of alleviating some of the issues) and then second-guessed if it was worth posting, but I then thought about this:

What if it's already possible for level packs to have their own music folders stored with the pack and not in the music folder?

It turns out, it is! Suppose your pack is located in levels\My_Pack and you want to put the music in My_Pack\Music (as opposed to a My_Pack subfolder in the main music folder). We're already allowed to have our music in a subfolder of the main Music folder, and this is the feature we can abuse to accomplish this nonstandard music location.

The music selection box lets us type the filename in. This is useful because otherwise subfolders wouldn't work, and subfolders are useful since they mean we can store the music for a particular pack or author together to try to reduce the chance of name collisions. It would also be a pain to find the file you want if your music folder is filled with the music from several level packs, so typing it in lets us find it faster. Plus, even if we weren't allowed to type it in, we could just fill in the relevant information in a text editor. There is also nothing that stops us from nesting these subdirectories, which is still useful for something like Music\Author_Name\Pack_Name\[songs go here]. If we are in a command prompt and a certain subdirectory of some arbitrary directory, and we want out of that subdirectory, all we need to do is type
Code: [Select]
cd ..Now we have everything we need to put the music wherever we want: to put the music for the pack in levels\My_Pack\Music, all we need to do is type the following into the music selection box:
Code: [Select]
..\levels\My_Pack\Music\[song]
I'm not sure if this should be allowed, but the engine won't stop you.



It'd be pretty stupid to step outside the NeoLemmix base directory because from that point on who knows what the directory and filesystem might possibly look like, but it is allowed by the engine. Absolute paths, however, are not (which is a sensible design choice since there's absolutely no reason to use an absolute path since it likely won't work on anyone but the original creator's machine, unless by coincidence someone else uses the exact same folder structure).



I'd say that \..\ in the relative path probably shouldn't be allowed, but perhaps packs should be allowed their own internal music folder since this does have some utility for avoiding name collisions by keeping the pack entirely self-contained - though if we decide to go that route, we'd definitely want to discuss the exact rules for it, since it would probably be a useful feature to allow a structure that allows multiple packs by the same author to share music.

Offline namida

  • Administrator
  • Posts: 12398
    • View Profile
    • NeoLemmix Website
Re: [Probably don't do this] How to put music outside the music folder
« Reply #1 on: July 03, 2020, 07:18:30 PM »
Quote
allows multiple packs ... to share music.

This is actually a big part of why music isn't stored with packs.

It's known that this is possible. While this is definitely a "don't do this", I kind of feel it's one of those ones that isn't worth making a special effort to prevent. Absolute paths have no explicit prevention either - it's simply that the way the code is written in general (in particular, that upon startup NeoLemmix figures out the absolute path of the NL folder, and it looks for music files by combining this path + "Music" + the music name) doesn't work with an absolute path. In fact, relative paths working was initially an unintended side effect too - then when I realised the usefulness of it, I instead decided to make it an explicitly supported feature.
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline WillLem

  • Posts: 3345
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [Probably don't do this] How to put music outside the music folder
« Reply #2 on: July 05, 2020, 12:31:56 AM »
Hang on... surely the ability to put music in the main levelpack's directory is a good thing - it keeps everything associated with that levelpack (apart from styles, of course) to just the one folder.

Offline Proxima

  • Posts: 4562
    • View Profile
Re: [Probably don't do this] How to put music outside the music folder
« Reply #3 on: July 05, 2020, 01:20:08 AM »
That's more convenient for the pack designer, but having all the music in pack-specific subfolders in the music folder is more convenient for the end user, and in my opinion that matters more.

Offline Simon

  • Administrator
  • Posts: 3860
    • View Profile
    • Lix
Re: [Probably don't do this] How to put music outside the music folder
« Reply #4 on: July 05, 2020, 10:55:25 AM »
Interesting that there is this cultural discrepancy between tilesets and music. A pack can access the NL-installation-globally installed tilesets (in pack-independent folder) or come with its own tilesets (in its pack folder). I would have expected the music to follow the same culture, or the tilesets to follow the music culture.

But my world view of NL tilesets may be outdated; I'll have a chat with Icho today.

Edit: Discussed this with Icho. Tilesets must also be installed NL-installation-globally.

-- Simon
« Last Edit: July 05, 2020, 02:53:34 PM by Simon »

Offline namida

  • Administrator
  • Posts: 12398
    • View Profile
    • NeoLemmix Website
Re: [Probably don't do this] How to put music outside the music folder
« Reply #5 on: July 05, 2020, 06:41:18 PM »
In old-formats, a pack could come with tilesets and music built into it (in the NXP file). Either could also be put into the global installation. To do this in old formats, the creator must have released the music / styles standalone; they could not be extracted from an NXP file (or rather: no tool to do this was provided; someone with sufficient coding ability could of course extract it).

In new formats, both are always globally installed and there is no "prevent anyone else from using this" mechanism other than asking nicely.
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline WillLem

  • Posts: 3345
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [Probably don't do this] How to put music outside the music folder
« Reply #6 on: July 08, 2020, 01:56:49 AM »
That's more convenient for the pack designer, but having all the music in pack-specific subfolders in the music folder is more convenient for the end user, and in my opinion that matters more.

I agree that any file system should be most convenient for the end user, but I'm not sure how having the music in pack-specific subfolders in a separate "music" folder is any different to the levelpacks themselves having a "music" folder.

The way I see it, if someone wants to access the music from a specific pack, it would be easier if the music was in the levelpack. I don't know about you, but my music folder is extremely disorganised, because not everybody who makes content chooses to place their music in a pack-specific folder, some creators simply leave it loose - most likely because they're not sure how to make a level access the music file from a folder. I myself did that with the Xmas music - I've placed it all into a folder now, but it was loose previously.

So yeah - not sure I agree that having a music folder full of separate packs is any more convenient/easy than simply having the music bundled in with the level pack itself.

Offline Proxima

  • Posts: 4562
    • View Profile
Re: [Probably don't do this] How to put music outside the music folder
« Reply #7 on: July 08, 2020, 07:46:13 AM »
I don't know about you, but my music folder is extremely disorganised, because not everybody who makes content chooses to place their music in a pack-specific folder, some creators simply leave it loose - most likely because they're not sure how to make a level access the music file from a folder.

That is indeed a problem, but having identified it as a problem, we can find a solution. The forum should be much stricter about enforcing that all packs point to music in subfolders, and that complete levels + music downloads have the appropriate structure. Old packs can be tidied up and made to conform to this, just as they can be updated to be compatible with new versions of NL when formats or physics change. It's tedious busywork, but the number of packs is small enough that it can be done.

Quote
I agree that any file system should be most convenient for the end user, but I'm not sure how having the music in pack-specific subfolders in a separate "music" folder is any different from the levelpacks themselves having a "music" folder.

It means you have much fewer clicks to navigate from one pack's music to another, which you might do when looking through your collection for specific tracks, or just listening to the music outside the game. It also makes it a lot easier to check the size of your music collection or import it as a whole to another installation of NL.