Click here to Skip to main content
15,890,123 members
Home / Discussions / C#
   

C#

 
QuestionGeneric and Inheritance issue Pin
Revolty31-May-13 11:27
Revolty31-May-13 11:27 
AnswerRe: Generic and Inheritance issue Pin
Ron Beyer31-May-13 12:02
professionalRon Beyer31-May-13 12:02 
GeneralRe: Generic and Inheritance issue Pin
Revolty31-May-13 12:52
Revolty31-May-13 12:52 
GeneralRe: Generic and Inheritance issue Pin
Revolty31-May-13 13:18
Revolty31-May-13 13:18 
AnswerRe: Generic and Inheritance issue Pin
Bernhard Hiller2-Jun-13 22:38
Bernhard Hiller2-Jun-13 22:38 
GeneralRe: Generic and Inheritance issue Pin
Revolty3-Jun-13 11:46
Revolty3-Jun-13 11:46 
AnswerRe: Generic and Inheritance issue Pin
Keld Ølykke3-Jun-13 20:10
Keld Ølykke3-Jun-13 20:10 
Question24 bit to 16 bit on the fly Pin
fachura31-May-13 4:49
fachura31-May-13 4:49 
Hi !

I need help with converting 24 bit input to 16 bit "on the fly" im trying to record audio output, if the format is set to 24 bit depth i have problem with mix it down to one channel (sound is slower) here is the example wchich im using to convert if audio has 32 bit i dont know how to change this code if input has 24 bit
C#
byte[] newArray16Bit = new byte[e.BytesRecorded / 2];
short two;
float value;
for (int i = 0, j = 0; i < e.BytesRecorded; i += 4, j += 2)
{
    value = (BitConverter.ToSingle(e.Buffer, i));
    two = (short)(value * short.MaxValue);

    newArray16Bit[j] = (byte)(two & 0xFF);
    newArray16Bit[j + 1] = (byte)((two >> 8) & 0xFF);
}
byte[] mono = StereoToMono(newArray16Bit);
OutFile.Write(mono);

i found sample code to convert but it returns float[] i need byte:
C#
public float[] Convert24BitToFloat(byte[] input)
{
    int inputSamples = input.Length / 3; // 24 bit input
    float[] output = new float[inputSamples];
    int outputIndex = 0;
    var temp = new byte[4];
    for(int n = 0; n < inputSamples; n++)
    {
        // copy 3 bytes in
        Array.Copy(input,n*3,temp,0,3);
        int sample = BitConverter.ToInt32(temp,0);
        output[outputIndex++] = sample / 16777216f;
    }
    return output;
}

AnswerRe: 24 bit to 16 bit on the fly Pin
Bernhard Hiller2-Jun-13 22:42
Bernhard Hiller2-Jun-13 22:42 
QuestionCalculate code complexity Pin
gastonbed30-May-13 22:49
gastonbed30-May-13 22:49 
QuestionRe: Calculate code complexity Pin
Eddy Vluggen30-May-13 23:40
professionalEddy Vluggen30-May-13 23:40 
AnswerRe: Calculate code complexity Pin
Alan Balkany31-May-13 4:56
Alan Balkany31-May-13 4:56 
GeneralRe: Calculate code complexity Pin
Eddy Vluggen31-May-13 6:25
professionalEddy Vluggen31-May-13 6:25 
GeneralRe: Calculate code complexity Pin
Alan Balkany31-May-13 9:33
Alan Balkany31-May-13 9:33 
GeneralRe: Calculate code complexity Pin
Eddy Vluggen31-May-13 11:01
professionalEddy Vluggen31-May-13 11:01 
QuestionProblem about menustrip in windows forms Pin
Arun kumar Gautam30-May-13 20:35
Arun kumar Gautam30-May-13 20:35 
AnswerRe: Problem about menustrip in windows forms Pin
Richard MacCutchan30-May-13 21:14
mveRichard MacCutchan30-May-13 21:14 
GeneralRe: Problem about menustrip in windows forms Pin
Arun kumar Gautam30-May-13 21:29
Arun kumar Gautam30-May-13 21:29 
GeneralRe: Problem about menustrip in windows forms Pin
Richard MacCutchan30-May-13 21:45
mveRichard MacCutchan30-May-13 21:45 
GeneralRe: Problem about menustrip in windows forms Pin
Arun kumar Gautam30-May-13 21:50
Arun kumar Gautam30-May-13 21:50 
GeneralRe: Problem about menustrip in windows forms Pin
Richard MacCutchan30-May-13 21:52
mveRichard MacCutchan30-May-13 21:52 
GeneralRe: Problem about menustrip in windows forms Pin
Arun kumar Gautam30-May-13 22:01
Arun kumar Gautam30-May-13 22:01 
GeneralRe: Problem about menustrip in windows forms Pin
Richard MacCutchan30-May-13 23:18
mveRichard MacCutchan30-May-13 23:18 
GeneralRe: Problem about menustrip in windows forms Pin
Arun kumar Gautam31-May-13 0:38
Arun kumar Gautam31-May-13 0:38 
QuestionEdit text file using C# Pin
srikanth kamuju29-May-13 22:21
professionalsrikanth kamuju29-May-13 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.