Background:
I'm working on writing a software application where I need to cross fade between 2 digital audio signals. In the software I have 4 variables that play a role:
float sampleA; //The value of signal A in this very instant (values from -1 to 1).
float sampleB; //The value of signal B in this very instant (values from -1 to 1).
float index; //The index of the crossfade in this very instant (values from 0 to 1).
float result; //The resulting value of the signal after the crossfade is applied.
However I have no idea how I would achieve this crossfade.
Problem Description:
I've decided to make a visual representation of the problem:
As you can see we have 3 number lines A(blue), B(red), and i(green). A and B represent the 2 floating point values of sampleA and sampleB which can vary between 1 and -1 while i is the crossfade index, a value which determines how far into the crossfade we are. Now what I've done is I've added some values for A, B and i on their respective numberlines and I've connected the points for A and B with a line.
If we then project the value of i on the line between point A and B we get a new point, Let's call this point R. If we project point R on either the numberline for A or B we can then get the final result.
Problem:
What is a formula which I can use, given a value for A, B and i, to calculate the value of R projected on the numberline?

From the visual I interpret this as $$R=a+i(b-a)$$ because the value of $R$ is equal to that of $a$ plus some fraction $i$ of the difference between $b$ and $a$.