With martial weapons, we're comparing out guns to longbows and their composite versions. Anyone focusing on weapon use will almost certainly have martial weapon proficiency at the least, so comparisons to optimized damage dealers start here.
Pistol is a light ranged weapon with which you can make multiple attacks without reloading, a distinct option not available normally. The nearest equivalent would be a hand crossbow (exotic) with either a
spell or weapon property that allows for automatic reloading (Rapid Reload/Hand Crossbow Focus also give free action reloading, but that still requires a second hand free preventing most of the goodies of using a light weapon). The range increment is very short compared to a longbow, but you're trading that range for using a light weapon instead of a two-handed one.
The rifle is about the same at a glance as a longbow. The range is slightly lower than a composite longbow, but the difference is minimal and they both have ranges more than long enough for most purposes.
- Basic crystals deal the same base damage as a non-composite longbow shot. Dedicated archers rarely have a high Str score, so it's unlikely for the composite damage bonus to really run away, but it's worth mentioning. Lack of crits means a ~10% damage loss. Arrows have negligible cost (0.05 gp/shot, 50% reusable on miss). Ballistics are 4.5 gp/shot and energies are 10.5 gp/shot.
- Targeted crystals deal only +1 average damage over a grade 1 crystal, yet cost 2x as much. A dedicated ranged character can be assumed to have some damage bonuses to offset the lower base damage (still at -2 vs. a longbow). By lower-mid levels, you can expect to hit the fixed AC 10 on every attack except on a natural 1. Cost is 9 gp/shot or 21 gp/shot, but since the touch attack of energy crystals doesn't count there's little point in paying more for them.
- Splash crystals are mildly effective now. With some actual damage bonuses, the splash damage can add up to something useful, and archer accuracy means that the -2 penalty on attack rolls isn't much of a hindrance. 9 gp/shot for ballistic or 21 gp/shot for energy.
- HEX crystals deal straight extra damage. A composite (+4 Str) longbow does the same amount after including the 10% bonus from having the potential for crits. Archers aren't as likely to have that high Str scores without enhancement items, though; usually Str scores are 10-14, depending on how stats are generated. HEX costs 13.5 gp/shot for ballistic and 31.5 gp/shot for energy, so it starts to chew through the money.
In summary, rifles are about the same as a longbow, but much more expensive in exchange for having some extra options. Pistols fill a different niche, the one that hand crossbows occupy, and they blow them out of the water. So if you want to TWF with ranged weapons, martial guns are worth the cost (and it will be a significant cost).