Raised This Month: $ Target: $400
 0% 

[INC]SoundInfo


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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, 604 views)
__________________

Last edited by DarkGL; 01-15-2012 at 15:37.
DarkGL is offline
 



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 13:49.


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