So no one answered this question, so I finally went ahead and solved it in case anyone is every curious about this. If there are any errors, please let me know. Also, I copied/pasted this from my own Latex document, so I may have missed some of the translation to MathJax.
In the most general case, the terminating impedances at each end of the duct in Fig. 1 are complex. This arrises from the fact that, in the most general situation, there will be standing waves formed inside the duct to the left of 1 and to the right of 2.
There are situations where it is possible to have no standing waves after the interface, which would then make the impedance real. These situations can occur in practical scenarios where the disturbances exits into open atmosphere or terminates at a rigid, lossless wall, or if the pipe length downstream of the interface is so long that viscous losses attenuate the reflected signal to such a degree that it is negligible compared to the incident wave by the time the wave returns to the interface ($Z_1$ or $Z_2$).
In order to study the most general case, lets assume that $Z_1$ and $Z_2$ are complex. In addition, lets again make the assumption that the waves are time harmonic, and are given by
$$
p'(x,t) = P(x)e^{i\omega t} = \Big[Ae^{-ikx} + Be^{ikx}\Big]e^{i\omega t}
$$
$$
u'(x,t) = U(x)e^{i\omega t} = \frac{1}{Z_0}\Big[Ae^{-ikx} - Be^{ikx}\Big]e^{i\omega t}
$$
Since we are letting the impedances to be any arbitrary complex value, it turns out that it is relatively useless to try and solve for the coefficients directly. Doing this creates excessively complicated equations that don't reveal anything useful about the dominant modes inside the pipe. It turns out to be much more revealing to study the process through appropriate boundary conditions. We can arrive at a very general boundary condition by looking at the linearized momentum equation given by
$$
\frac{\partial u'}{\partial t} + \frac{1}{\rho_0}\frac{\partial p'}{\partial x} = 0
$$
Plugging the pressure and velocity equations into the momentum equation, and noting that $\frac{p'(x,t)}{u'(x,t)} = z(x)$, where $z(x)$ is the mechanical impedance, we get
$$\nonumber
i\omega \rho_0 P(x) + z(x)\frac{dP}{dx} = 0
$$
Noting that $\omega = c_0k$ and $z_0 = \rho_0 c_0$, and dividing by the area A(x), we get
$$
ik\frac{z_0}{A(x)}P(x) + \frac{z(x)}{A(x)}\frac{dP}{dx} = 0
$$
Here $z_0$ is the specific acoustic impedance of the pipe. It's important to note that this is a real valued quantity. Finally, noting that the acoustic impedance is given by $Z_i = \frac{z_i}{A(x)}$, we have
$$
ikZ_0P(x) + Z(x)\frac{dP}{dx} = 0
$$
This is a general B.C. and can be applied to any point within the pipe, but it is important to note that the area can change, thus the correct $A(x)$ value must be used. Applying this B.C. to $x = 0$, we get
$$
ikZ_0\big[A + B\big] + Z_1\big[-ikA + ikB\big] = 0
$$
Grouping all the terms, we arrive at our first B.C.
$$
\Big(1 - \frac{Z_1}{Z_0}\Big)A + \Big(1 + \frac{Z_1}{Z_0}\Big)B = 0
$$
Applying the B.C. to $x = L$, we get
$$
Ae^{-ikL} + Be^{ikl} + \frac{Z_2}{Z_0}\Big[-Ae^{-ikL} + Be^{ikL}\Big] = 0
$$
Finally, grouping all the terms, we arrive at our last B.C.
$$
\Big(1 - \frac{Z_2}{Z_0}\Big)e^{-ikL}A + \Big(1 + \frac{Z_2}{Z_0}\Big)e^{ikL}B = 0
$$
These can be put into matrix form to get
$$
\begin{bmatrix}
&\Big(1 - \frac{Z_1}{Z_0}\Big) &\Big(1 + \frac{Z_1}{Z_0}\Big) \\
&\Big(1 - \frac{Z_2}{Z_0}\Big)e^{-ikL} &\Big(1 + \frac{Z_2}{Z_0}\Big)e^{ikL} \\
\end{bmatrix}
\begin{bmatrix}
&A& \\
&B&
\end{bmatrix}
=
\begin{bmatrix}
&0& \\
&0&
\end{bmatrix}
$$
The coefficients A and B only have a nontrivial solution when the determinant of the matrix is zero
$$
\begin{vmatrix}
&\Big(1 - \frac{Z_1}{Z_0}\Big) &\Big(1 + \frac{Z_1}{Z_0}\Big) \\
&\Big(1 - \frac{Z_2}{Z_0}\Big)e^{-ikL} &\Big(1 + \frac{Z_2}{Z_0}\Big)e^{ikL} \\
\end{vmatrix}
= 0
$$
Solving for the determinant we get
$$
\Big(1-\frac{Z_1}{Z_0}\Big)\Big(1+\frac{Z_2}{Z_0}\Big)e^{ikL} - \Big(1-\frac{Z_2}{Z_0}\Big)\Big(1 + \frac{Z_1}{Z_0}\Big)e^{-iKL} = 0
$$
Defining the reflection coefficients as
$$
R_1 \equiv \frac{\frac{Z_1}{Z_0} - 1}{\frac{Z_1}{Z_0} + 1}
$$
$$
R_2 \equiv \frac{\frac{Z_2}{Z_0} - 1}{\frac{Z_2}{Z_0} + 1}
$$
We finally arrive at the condition
$$
e^{i2kL} = \frac{R_2}{R_1}
$$
The reflection coefficients defined here are the reflection the wave inside the pipe would see when approaching either of the interfaces. Due to the fact that $Z_1$ and $Z_2$ are, in general, complex, then we can expect $R_1$ and $R_2$ to also be complex, thus the condition becomes
$$
e^{i2kL} = \frac{|R_2|}{|R_1|}e^{i(\theta_2 - \theta_1)}
$$
Before jumping on to the most general case, lets take a look at a couple of limiting cases:
- Equal Reflection with Positive Orientation
In the case that $\frac{R_2}{R_1} = 1$, the wave would see the exact same reflection at either interface, thus we must have $Z_1 = Z_2$. The very limiting case where we have an open-open or closed-closed boundaries are a subset of this class of boundary conditions. It is clear that this condition only holds when
$$
\sin{kL} = 0
$$
which means that
$$
kL = n\pi
$$
Where n = 1,2,3,...As long as the impedances are the same (does not have to be open-open or closed-closed), we will always have $\frac{\lambda}{2}$ modes.
- Equal Reflection with Negative Orientation
In the case that $\frac{R_2}{R_1} = -1$, the wave would see the exact same magnitude of reflection at each end, but its sign would be opposite of that on the other end of the pipe. For the case of real impedances, that means $\frac{Z_i}{Z_0} < 1$ on one of the interfaces and $\frac{Z_i}{Z_0} > 1$ on the other. This means that
$$
e^{i2kL} = -1
$$
Taking the complex log of each side, and noting the periodicity of the complex exponential, we have
$$
i2\Big[kL - n\pi] = \ln{1} + i\pi
$$
where we used the identity that $\ln{(-a)} = \ln{(a)} + i\pi$. Solving for $kL$, we get
$$
kL = \frac{\pi}{2}(2n + 1)
$$
Where $n = \pm 1,2,3,...$. Or more simply
$$
kL = m\frac{\pi}{2}
$$
Where $m = \pm 1,3,5,...$. This is a really interesting limiting case because we can get some valuable insight into the problem without solving the coefficients. If we set $R2 = - R1$, we get
$$
(\frac{Z_2}{Z_0} - 1)(\frac{Z_1}{Z_0} + 1) = -(\frac{Z_1}{Z_0} - 1)(\frac{Z_2}{Z_0} + 1)
$$
And solving this, we come to the requirement that $Z_1Z_2 = Z_0^2$. Since $Z_0 = \frac{\rho_0 c_0}{A}$ is a real-value parameter, then this equation will only hold if $Z_1 = Z_2*$. Thus we can write
$$
Z_0 = \sqrt[]{|Z_1||Z_2|}
$$
This means that as long as the impedance of the pipe, $Z_0 = \frac{\rho_0 c_0}{A}$, is the geometric mean of the terminating impedances, we will always have $\frac{\lambda}{4}$ modes! Furthermore, if the fluid properties (i.e. density and speed of sound) are the same, and the area inside the pipe is constant, then we will have quarter wavelength modes when the area of the pipe is the geometric mean of the areas of the pipes upstream and downstream of it.
$$
A_0 = \sqrt[]{A_1A_2}
$$
- Constant Phase
If on the other hand, we have $\theta_2 = \theta_1$, then the condition becomes
$$
e^{2ikL} = \frac{|R_2|}{|R_1|}
$$
Taking the complex log of both sides, we get
$$
2i\Big[kL - n\pi\Big] = \ln{\Bigg(\frac{|R_2|}{|R_1|}\Bigg)}
$$
And we can solve for the wavenumber to get
$$
kL = n\pi - i\frac{1}{2}\ln{\Bigg(\frac{|R_2|}{|R_1|}\Bigg)}
$$
Where $n = 0,\pm[1,2,3,...]$. But what does a complex wavenumber physically mean? Let's plug it back into the time harmonic eq. to find out (for n = 1). The x-component of the pressure equation gives
$$
P(x) = \Bigg[\Big(\frac{|R_2|}{|R_1|}\Big)^{\frac{-x}{2L}}A\Bigg]e^{-i\frac{\pi}{L}x} + \Bigg[\Big(\frac{|R_2|}{|R_1|}\Big)^{\frac{x}{2L}}B\Bigg]e^{i\frac{\pi}{L}x}
$$
It is clear that the contribution from the magnitude ratio is to simply affect the amplitude of the incident and reflected wave so that it meets the boundary conditions, and that it provides no contribution to the oscillating frequency. The time component of the wavenumber gives
$$
e^{i\omega t} = \Bigg[\Big(\frac{|R_2|}{|R_1|}\Big)^{\frac{ct}{2L}}\Bigg]e^{i\frac{\pi c}{L}t}
$$
It is clear that $\frac{|R_2|}{|R_1|}$ is a "damping" factor. This makes physical sense. Since we are looking at free motion (i.e. not forced harmonics), then unless $|R_2| = |R_1| = 1$, some portion of the wave will transmit through the interface and carry energy away with it. Thus we should expect for the wave to die down as $t \rightarrow \infty$. This is true for as long as $\frac{|R_2|}{|R_1|} < 1$, but if $\frac{|R_2|}{|R_1|} > 1$, then $p'(x,t) \rightarrow \infty$ as $t \rightarrow \infty$.
To summarize, if the phase difference is equal, then we will always have $\frac{\lambda}{2}$ modes regardless of the magnitude ratio of the reflection coefficients. The only role they have is to provide amplitude change.
- $\pi$ Phase Difference
If $\theta_2 = \theta_1 + \pi$, then we have
$$
e^{2ikL} = -\frac{|R_2|}{|R_1|}
$$
This can be solved in a similar way to get
$$
kL = n\frac{\pi}{2} - i\frac{1}{2}\ln{\Bigg(\frac{|R_2|}{|R_1|}\Bigg)}
$$
Where $n = 0,\pm[1, 3, 5, ...]$. This means that as long as the phase difference is off by a factor of $\pi$, then the resonant modes will always be $\frac{\lambda}{4}$ modes regardless of the magnitude difference.
- General Case
The most general condition is that
$$
2i\Big[kL - n\pi\Big] = i(\theta_2 - \theta_1) + \ln{\Bigg(\frac{|R_2|}{|R_1|}\Bigg)}
$$
Thus the wavenumber must be
$$
kL = n\pi + \frac{1}{2}(\theta_2 - \theta_1) - i\frac{1}{2}\ln{\Bigg(\frac{|R_2|}{|R_1|}\Bigg)}
$$
Where $n = 0,\pm[1, 2, 3, ...]$.
As discussed previously, the only component that affects the oscillating frequency is the phase difference between the two interfacial reflections. If these are very small, $\frac{\theta_2}{\theta_1} \sim 1$, then we will simply have half-wavelengths modes. What is really interesting about these results is that they only depend on the boundaries, and not on what is going on within the pipe provided that the fluid is homogenous (i.e. the wavenumber stays the same).