As the number of players increases you will have many more mixed doubles opponents than there are opposite sex partners, so you will need some other criterion to optimise. The best solutions to these problems are where you prevent spouse pairs from playing in a match together. For example 8 players:
(H1 W3 v H4 W2) (H2 W4 v H3 W1)
(H1 W2 v H3 W4) (H2 W1 v H4 W3)
(H1 W4 v H2 W3) (H3 W2 v H4 W1)
for other shedules follow the links:
10 players
such a schedule for 12 players does not exist (mathematically impossible).
16 players
18 players
32 players
Hope that helps.