Raised This Month: $51 Target: $400
 12% 

[INC]SoundInfo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarkGL
Senior Member
Join Date: Aug 2010
Location: Warsaw, Poland
Old 01-15-2012 , 15:37   [INC]SoundInfo
Reply With Quote #1

SoundInfo by R3X & DarkGL

This lib give you few new function for operating on sound files
  • sfile_get_duration(szFilename[])
    Return duration of sound ( Float ) it's not work on mp3 files encoded with dynamic bitrate ( VBR )
    First parametr is path to the file.
  • get_duration(iData[SParam])
    Also return duration of sound ( Float ) as sfile_get_duration it's not work on mp3 files with VBR
    Parametr is table with information load with sfile_loaddata()
  • sfile_is_valid(szFilename[])
    Return true or false if sound can be played in cs
  • sfile_type(szFilename[])
    Return what type of file is it
    • SFILE_MP3
    • SFILE_WAV
    • SFILE_UNKNOWN
  • sfile_loaddata(szFilename[], iData[SParam])
    Load information about song return SRES_NOT_EXISTS if not found file
    For mp3 file return
    • SRES_BAD_PARAMETERS
    • SRES_OK
    For wav file
    • SRES_BAD_SIGNATURE
    • SRES_OK
    First parametr is path to file
    Second is special table where information about song will be writen
    • SOUND_FREQ - frequence of sound
    • SOUND_BYTERATE - byterate
    • SOUND_CHAN_NUM - ammount of channels
    • SOUND_DURATION_F - duration of sound to get this use
      • Float:iData[SOUND_DURATION_F])
      • get_duration(iData)
  • sfile_loaddata_mp3(szFilename[], iData[SParam])
    Same as sfile_loaddata but only for mp3 files
  • sfile_loaddata_wav(szFilename[], iData[SParam])
    Same as sfile_loaddata but only for wav files

Example:
Code:
#include <amxmodx>
#include <amxmisc>
#include <soundinfo>

#define PLUGIN "Wav"
#define VERSION "1.0"
#define AUTHOR "R3X"


public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR);
        
        register_clcmd("sinfo", "sinfo",0, "<sound> //path from cstrike");
}
public sinfo(id){
        new szFilename[32];
        read_argv(1, szFilename, 31);
        
        switch(sfile_type(szFilename)){
                case SFILE_MP3: log_amx("MP3");
                case SFILE_WAV: log_amx("WAV");
                default: log_amx("UNKNOWN");
        }
        
        new iData[SParam];
        if(sfile_loaddata(szFilename, iData) == SRES_OK){
                client_print(id, print_console, "Freq = %d", iData[SOUND_FREQ]);
                client_print(id, print_console, "ByteRate = %d", iData[SOUND_BYTERATE]);
                client_print(id, print_console, "Channels = %d", iData[SOUND_CHAN_NUM]);
                client_print(id, print_console, "Duration = %f", Float:iData[SOUND_DURATION_F]);
                                client_print(id, print_console, "Duration = %f", sfile_get_duration(szFilename));
                                
                
                if(sfile_is_valid(szFilename))
                        client_print(id, print_console, "Valid!");
                else
                        client_print(id, print_console, "Invalid!");
        }
        return PLUGIN_HANDLED
}
Attached Files
File Type: inc soundinfo.inc (8.3 KB, 597 views)
__________________

Last edited by DarkGL; 01-15-2012 at 15:37.
DarkGL is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 01-15-2012 , 16:12   Re: [INC]SoundInfo
Reply With Quote #2

Great, thank you!
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-16-2012 , 00:30   Re: [INC]SoundInfo
Reply With Quote #3

Thanks, though some ways were avalaible in sanksound, your way seems better
What about dynamic bitrate mp3 ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 01-26-2013 , 21:10   Re: [INC]SoundInfo
Reply With Quote #4

I am trieing to check if sounds are valid. Somehow both doesn't work (changed the mono settings and such). But when I try to call it with the "spk" command in console, both work fine. Is something in the sfile_is_valid function wrong?
Attached Files
File Type: zip test.zip (473.6 KB, 243 views)
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 05-03-2013 , 12:07   Re: [INC]SoundInfo
Reply With Quote #5

bump
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 05-20-2013 , 12:07   Re: [INC]SoundInfo
Reply With Quote #6

Quote:
Originally Posted by bibu View Post
bump
bump
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Old 05-23-2013, 07:02
Kelgha
This message has been deleted by Arkshine. Reason: Spambot
bibu
Veteran Member
Join Date: Sep 2010
Old 01-11-2014 , 20:27   Re: [INC]SoundInfo
Reply With Quote #7

Quote:
Originally Posted by bibu View Post
bump
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-12-2014 , 11:25   Re: [INC]SoundInfo
Reply With Quote #8

Code:
return ((iData[SOUND_CHAN_NUM] == 1) && (iData[SOUND_BYTERATE] == 22050) );
Try to remove the byterate check. I'm not sure checking a specific value is a good idea.
__________________
Arkshine is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-13-2014 , 00:52   Re: [INC]SoundInfo
Reply With Quote #9

bitrate doesn't count, you are right.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-13-2014 , 09:38   Re: [INC]SoundInfo
Reply With Quote #10

More infos ?
__________________
Arkshine is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:56.


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