AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   [EXTENSION] Sound Info Library v1.0.1 (https://forums.alliedmods.net/showthread.php?t=105816)

Fyren 08-05-2018 08:17

Re: [EXTENSION] Sound Info Library v1.0.1
 
You need, at least, the 32-bit version of libz. You can ask the server host/owner to install it.

There may be other missing 32-bit libraries. If you have shell access, you can run ldd on the extension to see.

blaisefps 01-28-2020 21:17

Re: [EXTENSION] Sound Info Library v1.0.1
 
[18] <FAILED> file "soundlib.ext.so": libz.so.1: cannot open shared object file: No such file or directory


help? pls

AdRiAnIlloO 11-04-2021 16:07

Re: [EXTENSION] Sound Info Library v1.0.1
 
Hi there,

Quote:

Originally Posted by MAGNAT2645 (Post 2546393)
This does not work correctly with VPKs (like TF2's sound/vo/ folder)

Code:

TagLib: Could not open file /home/tf2/serverfiles/tf/sound/vo/sniper_item_birdhead_round_start02.mp3

Quote:

Originally Posted by StrikerMan780 (Post 2344058)
Bump from hell, but is there a chance this could be updated to support getting the length of a song or sound that's inside a VPK or the SteamPipe folders?

In case it's still useful for anyone, I've edited SoundLib to support reading from VPKs (more generally, from any gameinfo.txt search path).

Download from: https://github.com/Adrianilloo/soundlib/releases

However, it's worth to note that, funny enough, at least for HL2MP, server-side sound VPKs don't contain the sound/music files themselves -which was probably done by Valve to save space-, making it necessary to copy VPKs from client anyway (or extract the relevant song files using GCFScape).

Cya!

MAGNAT2645 11-05-2021 13:49

Re: [EXTENSION] Sound Info Library v1.0.1
 
Quote:

Originally Posted by AdRiAnIlloO (Post 2762503)
Hi there,





In case it's still useful for anyone, I've edited SoundLib to support reading from VPKs (more generally, from any gameinfo.txt search path).

Download from: https://github.com/Adrianilloo/soundlib/releases

However, it's worth to note that, funny enough, at least for HL2MP, server-side sound VPKs don't contain the sound/music files themselves -which was probably done by Valve to save space-, making it necessary to copy VPKs from client anyway (or extract the relevant song files using GCFScape).

Cya!

Hi. Can you please also implement methodmap natives (in the extension) from this?
Code:

methodmap SoundFile < Handle {
    /**
    * Opens a sound file.
    *
    * @note Sound files are closed with CloseHandle().
    *
    * @param file                File to open
    * @param relativeToSound    if true, it is relative to the sound directory, otherwise you have to build the path yourself
    * @return                    A Handle to the sound file, null on open error.
    */
    public SoundFile(const char[] file, bool relativeToSound=true) { return view_as< SoundFile >( OpenSoundFile( file, relativeToSound ) ); }

    /**
    * Gets the length of the sound file in seconds
    *
    * @return                    The song length in seconds
    */
    property int Length {
        public get() { return GetSoundLength( this ); }
    }

    /**
    * Gets the length of the sound file in seconds as float.
    * Note: this probably won't work with some VBR encoded mp3's
    *
    * @return                    The song length in seconds as float
    */
    property float LengthFloat {
        public get() { return GetSoundLengthFloat( this ); }
    }

    /**
    * Get the Bit rate of sound (kbps)
    *
    * @return                    Sound bitrate (cell)
    */
    property int BitRate {
        public get() { return GetSoundBitRate( this ); }
    }

    /**
    * Get the Sampling rate of sound (hz)
    *
    * @return                    Sampling rate (cell)
    */
    property int SamplingRate {
        public get() { return GetSoundSamplingRate( this ); }
    }

    /**
    * Get the Artist of the sound
    *
    * @param buffer              Buffer to use for storing the string.
    * @param maxlength          Maximum length of the buffer.
    * @return                    Length of string written to buffer.
    */
    public int GetArtist(char[] buffer, int maxlength) { return GetSoundArtist( this, buffer, maxlength ); }

    /**
    * Get the Track title of sound
    *
    * @param buffer              Buffer to use for storing the string.
    * @param maxlength          Maximum length of the buffer.
    * @return                    Length of string written to buffer.
    */
    public int GetTitle(char[] buffer, int maxlength) { return GetSoundTitle( this, buffer, maxlength ); }

    /**
    * Get the Track number of the sound
    *
    * @return                    Sound number (cell)
    */
    property int Number {
        public get() { return GetSoundNum( this ); }
    }

    /**
    * Get the Album of the sound
    *
    * @param buffer              Buffer to use for storing the string.
    * @param maxlength          Maximum length of the buffer.
    * @return                    Length of string written to buffer.
    */
    public int GetAlbum(char[] buffer, int maxlength) { return GetSoundAlbum( this, buffer, maxlength ); }

    /**
    * Get the Year of sound
    *
    * @return                    Sound year (cell)
    */
    property int Year {
        public get() { return GetSoundYear( this ); }
    }

    /**
    * Get the Comment of the sound
    *
    * @param buffer              Buffer to use for storing the string.
    * @param maxlength          Maximum length of the buffer.
    * @return                    Length of string written to buffer.
    */
    public int GetComment(char[] buffer, int maxlength) { return GetSoundComment( this, buffer, maxlength ); }

    /**
    * Get the Genre of the sound
    *
    * @param buffer              Buffer to use for storing the string.
    * @param maxlength          Maximum length of the buffer.
    * @return                    Length of string written to buffer.
    */
    public int GetGenre(char[] buffer, int maxlength) { return GetSoundGenre( this, buffer, maxlength ); }
};

So it doesn't have to be a wrapper.

AdRiAnIlloO 11-08-2021 11:11

Re: [EXTENSION] Sound Info Library v1.0.1
 
Quote:

Originally Posted by MAGNAT2645 (Post 2762569)
Hi. Can you please also implement methodmap natives (in the extension) from this?
Code:

methodmap SoundFile < Handle {
    /**
    * Opens a sound file.
    *
    * @note Sound files are closed with CloseHandle().
    *
    * @param file                File to open
    * @param relativeToSound    if true, it is relative to the sound directory, otherwise you have to build the path yourself
    * @return                    A Handle to the sound file, null on open error.
    */
    public SoundFile(const char[] file, bool relativeToSound=true) { return view_as< SoundFile >( OpenSoundFile( file, relativeToSound ) ); }

    /**
    * Gets the length of the sound file in seconds
    *
    * @return                    The song length in seconds
    */
    property int Length {
        public get() { return GetSoundLength( this ); }
    }

    /**
    * Gets the length of the sound file in seconds as float.
    * Note: this probably won't work with some VBR encoded mp3's
    *
    * @return                    The song length in seconds as float
    */
    property float LengthFloat {
        public get() { return GetSoundLengthFloat( this ); }
    }

    /**
    * Get the Bit rate of sound (kbps)
    *
    * @return                    Sound bitrate (cell)
    */
    property int BitRate {
        public get() { return GetSoundBitRate( this ); }
    }

    /**
    * Get the Sampling rate of sound (hz)
    *
    * @return                    Sampling rate (cell)
    */
    property int SamplingRate {
        public get() { return GetSoundSamplingRate( this ); }
    }

    /**
    * Get the Artist of the sound
    *
    * @param buffer              Buffer to use for storing the string.
    * @param maxlength          Maximum length of the buffer.
    * @return                    Length of string written to buffer.
    */
    public int GetArtist(char[] buffer, int maxlength) { return GetSoundArtist( this, buffer, maxlength ); }

    /**
    * Get the Track title of sound
    *
    * @param buffer              Buffer to use for storing the string.
    * @param maxlength          Maximum length of the buffer.
    * @return                    Length of string written to buffer.
    */
    public int GetTitle(char[] buffer, int maxlength) { return GetSoundTitle( this, buffer, maxlength ); }

    /**
    * Get the Track number of the sound
    *
    * @return                    Sound number (cell)
    */
    property int Number {
        public get() { return GetSoundNum( this ); }
    }

    /**
    * Get the Album of the sound
    *
    * @param buffer              Buffer to use for storing the string.
    * @param maxlength          Maximum length of the buffer.
    * @return                    Length of string written to buffer.
    */
    public int GetAlbum(char[] buffer, int maxlength) { return GetSoundAlbum( this, buffer, maxlength ); }

    /**
    * Get the Year of sound
    *
    * @return                    Sound year (cell)
    */
    property int Year {
        public get() { return GetSoundYear( this ); }
    }

    /**
    * Get the Comment of the sound
    *
    * @param buffer              Buffer to use for storing the string.
    * @param maxlength          Maximum length of the buffer.
    * @return                    Length of string written to buffer.
    */
    public int GetComment(char[] buffer, int maxlength) { return GetSoundComment( this, buffer, maxlength ); }

    /**
    * Get the Genre of the sound
    *
    * @param buffer              Buffer to use for storing the string.
    * @param maxlength          Maximum length of the buffer.
    * @return                    Length of string written to buffer.
    */
    public int GetGenre(char[] buffer, int maxlength) { return GetSoundGenre( this, buffer, maxlength ); }
};

So it doesn't have to be a wrapper.

Done: https://github.com/Adrianilloo/sound...e/soundlib.inc

Thanks for your contribution.

Sample output from working methodmap based API:

Code:

sm plugins reload soundlib_demo
[SM] Plugin soundlib test reloaded successfully.
sm_soundinfo 02 CP Violation.mp3
Song Info 02 CP Violation.mp3
Sound Length: 105
Sound Length (float): 105.508575
Birate: 320
Sampling Rate: 44100
Artist: Valve
Title: CP Violation
Num 2
Album: The Soundtrack of Half-Life 2
Year: 2004
Comment: 0
Genre: Soundtrack

If you're going to test sounds from VPKs (and/or additional search paths), or just my upgraded extension in general, let me know how it goes (whether you find any issue etc.).

[+General info: I recently added support to SaySounds plugin (which uses SoundLib) with required edits to support VPK / search path reading as well, which requires my edited SoundLib: https://github.com/Gh0sty/SaysoundsHE]

MAGNAT2645 11-09-2021 05:09

Re: [EXTENSION] Sound Info Library v1.0.1
 
Quote:

Originally Posted by AdRiAnIlloO (Post 2762864)
Done: https://github.com/Adrianilloo/sound...e/soundlib.inc

Thanks for your contribution.

Sample output from working methodmap based API:

Code:

sm plugins reload soundlib_demo
[SM] Plugin soundlib test reloaded successfully.
sm_soundinfo 02 CP Violation.mp3
Song Info 02 CP Violation.mp3
Sound Length: 105
Sound Length (float): 105.508575
Birate: 320
Sampling Rate: 44100
Artist: Valve
Title: CP Violation
Num 2
Album: The Soundtrack of Half-Life 2
Year: 2004
Comment: 0
Genre: Soundtrack

If you're going to test sounds from VPKs (and/or additional search paths), or just my upgraded extension in general, let me know how it goes (whether you find any issue etc.).

[+General info: I recently added support to SaySounds plugin (which uses SoundLib) with required edits to support VPK / search path reading as well, which requires my edited SoundLib: https://github.com/Gh0sty/SaysoundsHE]

Thanks, but i meant native functions in the methodmap.
For example:
Code:

        property float LengthFloat
        {
                public native get();
        }

        property int Year
        {
                public native get();
        }

And native methods would be declared in the extension as natives.
Code:

sp_nativeinfo_t g_SoundLibraryNatives[] =
{
        {"OpenSoundFile",                        OpenSoundFile},
        {"GetSoundLength",                        GetSoundLength},
        {"GetSoundLengthFloat",                GetSoundLengthFloat},
        {"GetSoundBitRate",                        GetSoundBitRate},
        {"GetSoundSamplingRate",                GetSoundSamplingRate},
        {"GetSoundArtist",                        GetSoundArtist},
        {"GetSoundTitle",                                GetSoundTitle},
        {"GetSoundNum",                                GetSoundNum},
        {"GetSoundAlbum",                        GetSoundAlbum},
        {"GetSoundYear",                                GetSoundYear},
        {"GetSoundComment",                        GetSoundComment},
        {"GetSoundGenre",                        GetSoundGenre},

        // native methods
        {"SoundFile.LengthFloat.get",        GetSoundLengthFloat},
        {"SoundFile.Year.get",                  GetSoundYear},
        // and for all other native methods

        {NULL,                                        NULL},
};


AdRiAnIlloO 11-14-2021 18:56

Re: [EXTENSION] Sound Info Library v1.0.1
 
Alright,

Updated the extension again with the native connection of methodmap instead.

I didn't understand you at first and ended up thinking the wrong idea as I wasn't used to that kind of task.

OneMore 10-15-2022 21:22

Re: [EXTENSION] Sound Info Library v1.0.1
 
May I ask you to upload here the already compiled extension for Linux?
Unfortunately, I don't have access to the server command line to compile... :(

AdRiAnIlloO 10-17-2022 04:08

Re: [EXTENSION] Sound Info Library v1.0.1
 
Releases are here in the ZIP present, both for Linux and Windows: https://github.com/Adrianilloo/soundlib/releases

Alienmario 01-14-2024 16:09

Re: [EXTENSION] Sound Info Library v1.0.1
 
Quote:

Originally Posted by AdRiAnIlloO (Post 2791101)
Releases are here in the ZIP present, both for Linux and Windows: https://github.com/Adrianilloo/soundlib/releases

Hi, Couldn't open an issue so posting here.

I'm using this extension on both existent and nonexistent sound files. This works as expected.
However on linux there are errors being spammed in console:
Code:

Tried to Seek NULL file handle!
FS:  Tried to Read NULL file handle!

Could this be hidden?


All times are GMT -4. The time now is 03:00.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.