Raised This Month: $91 Target: $400
 22% 

VoiceHook - Developer preview of something.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-16-2010 , 10:48   VoiceHook - Developer preview of something.
Reply With Quote #1

This plugin hooks the broadcast of voice chat through the server, decompresses it with Valve's audio codecs, passes it onto other plugins that have registered a listener and then re-compresses the data.

WARNING: For TF2 and other games using the Steam audio system, you need to set the sv_use_steam_voice convar to 0 if you want decompression to work.

The interface is quite simple:
Code:
#define VOICE_INTERFACE "VOICE_INTERFACE_002"

class IVoiceListener
{
public:
	// In raw mode, nSamples = bytes;
	virtual void OnVoiceBroadcast(int client, char *pVoiceData, int *nSamples)
	{
	}
};

class IVoice
{
public:
	virtual void AddVoiceListener(IVoiceListener *pVoiceListener) = 0;
	virtual void RemoveVoiceListener(IVoiceListener *pVoiceListener) = 0;
	
	virtual void AddRawVoiceListener(IVoiceListener *pVoiceListener) = 0;
	virtual void RemoveRawVoiceListener(IVoiceListener *pVoiceListener) = 0;
};
and can be acquired with the following code:
Code:
IVoice *pVoice = (IVoice *)g_SMAPI->MetaFactory(VOICE_INTERFACE, NULL, NULL);
I'm fed up with typing, so have a load of files:
You'll need to copy vaudio_speex.dll from Steam\steamapps\<account name>\<Source 2009 using game name>\bin\ (Linux users can get the Linux one from here) and copy it to orangebox\bin in your server install.

TO-DO List:
  • Further reverse engineer the broadcast function, if it can be completely replaced we'll be able to avoid the terrible voice management functions.
  • Allow interface implementors to block the function.
  • Implement a method to get IServer, so we can broadcast arbitrary audio to clients.
__________________

Last edited by asherkin; 03-23-2013 at 02:32.
asherkin is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Brazil
Old 12-16-2010 , 11:31   Re: VoiceHook - Developer preview of something.
Reply With Quote #2

Needs moar source code
Seta00 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 12-16-2010 , 12:43   Re: VoiceHook - Developer preview of something.
Reply With Quote #3

Sorry, why would someone change the voicedata in a plugin ?

But it sounds great I always wanted to do this.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-16-2010 , 13:01   Re: VoiceHook - Developer preview of something.
Reply With Quote #4

Quote:
Originally Posted by berni View Post
Sorry, why would someone change the voicedata in a plugin ?
A few random ideas that have come up from people:
  • Decrease or increase the volume of a client's voice audio.
  • Pitch-shift it or other audio effects.

I really don't know tbh, it was a requested feature .
__________________
asherkin is offline
FaTony
BANNED
Join Date: Aug 2008
Old 12-16-2010 , 23:57   Re: VoiceHook - Developer preview of something.
Reply With Quote #5

Sampling rate? How many bits per sample?
FaTony is offline
raydan
Senior Member
Join Date: Aug 2006
Old 12-16-2010 , 23:59   Re: VoiceHook - Developer preview of something.
Reply With Quote #6

use voice audio channel stream mp3?
raydan is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-17-2010 , 00:03   Re: VoiceHook - Developer preview of something.
Reply With Quote #7

Quote:
Originally Posted by FaTony View Post
Sampling rate? How many bits per sample?
From voicerecord_ext:
Code:
WAVEFORMATEX g_VoiceSampleFormat =
{
	WAVE_FORMAT_PCM,	// wFormatTag
	1,			// nChannels
	11025,			// nSamplesPerSec
	22050,			// nAvgBytesPerSec
	2,			// nBlockAlign
	16,			// wBitsPerSample
	0			// cbSize
};
__________________
asherkin is offline
FaTony
BANNED
Join Date: Aug 2008
Old 12-17-2010 , 00:08   Re: VoiceHook - Developer preview of something.
Reply With Quote #8

And why no ability to create audio data from scratch? I wanna make my bots talk.
FaTony is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-17-2010 , 00:27   Re: VoiceHook - Developer preview of something.
Reply With Quote #9

Quote:
Originally Posted by FaTony View Post
And why no ability to create audio data from scratch? I wanna make my bots talk.
Quote:
Originally Posted by asherkin View Post
I'm still working on this heavily
I haven't finished that part yet.
__________________
asherkin is offline
PAL-18
AlliedModders Donor
Join Date: Jul 2010
Old 12-17-2010 , 17:22   Re: VoiceHook - Developer preview of something.
Reply With Quote #10

Quote:
Originally Posted by asherkin View Post
A few random ideas that have come up from people:
  • Decrease or increase the volume of a client's voice audio.
  • Pitch-shift it or other audio effects.

I really don't know tbh, it was a requested feature .
What about a voice recognition thing where it can pipe the voice to another program and based on what it detects execute server-side commands like ban people for saying the N word.
PAL-18 is offline
Reply


Thread Tools
Display Modes

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 03:03.


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